sentry-php icon indicating copy to clipboard operation
sentry-php copied to clipboard

Tracing: add support for strictTraceContinuation

Open Fabccc opened this issue 8 months ago • 3 comments

Problem Statement

When a 3rd party access our API's, it can set headers like "Traceparent" and "Tracestate", which trigger trace propagation on our backend, even though the trace sample rate is set to 0%. When navigating to solve the issue by configuring the SDK, I fumble on this https://develop.sentry.dev/sdk/telemetry/traces/#stricttracecontinuation, but I could find an equivalent for the PHP sdk, it was only available on Python or Javascript. I am missing something ?

Solution Brainstorm

This option should be able to ignore current trace propagation if sentry org are different base on the headers and the DSN set in the SDK.

Fabccc avatar May 06 '25 09:05 Fabccc

traces_sample_rate: 0 is different to traces_sample_rate: null. When setting null, we ignore any incoming traces, regardless their sample decision. The feature you linked to is currently not available in any SDK.

cleptric avatar May 06 '25 09:05 cleptric

Thank you for the clarification ! So I would have a look at the trace_propagation_targets attribute ? I know it applies to outgoing requests, but does it ignore incoming requests already tagged with traces header ? I couldn't find anything in the documentation for that

Fabccc avatar May 06 '25 10:05 Fabccc

You can overwrite the parent sampling decision with a traces_sampler. Besides this, we will ship strict_trace_continuation first in the PHP SDK, likely this week.

cleptric avatar May 12 '25 06:05 cleptric