限制跟踪传播

默认情况下,跟踪信息(sentry-tracebaggage 头)将被添加到所有传出的 HTTP 请求中。如果您希望限制添加跟踪信息的 URL,可以使用 trace_propagation_targets 选项进行指定:

Copied
import sentry_sdk

sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
    trace_propagation_targets=[
        "https://myproject.org",
        "https://.*\.otherservice.org/.*",
    ],
    # ...
)

在上面的示例中,跟踪信息将被添加到所有包含 myproject.org 的 URL 请求以及 otherservice.org 的所有子域名请求中,例如 https://api.otherservice.org/something/https://payment.otherservice.org/something/

有关 trace_propagation_targets 选项的更多信息,请参阅我们的配置选项文档。