Custom TracesSampler ignores sampling decision from sentry-trace header
See original GitHub issuePackage
Sentry.AspNetCore
.NET Flavor
.NET Core
.NET Version
6.0.0
OS
Any
SDK Version
3.17.1
Self-Hosted Sentry Version
No response
Steps to Reproduce
Set up an ASP.NET Core application, include .UseSentryTracing()
, and add a custom TracesSampler
:
webBuilder.UseSentry(o =>
{
o.TracesSampler = ctx =>
{
return 1;
}
})
Run it, make a request using Postman (or similar tool), and include the sentry-trace
HTTP request header:
sentry-trace: 00000000000000000000000000000000-0000000000000000-0
The -0
at the end indicates the transaction should not be sampled.
Expected Result
The transaction should not be sent to Sentry.
Actual Result
The transaction is sent to Sentry anyway, because the TracesSampler
return value overrides the value in the sentry-trace
header.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Guidelines for Performance Monitoring
Unlike with b3 headers, a sentry-trace header should never consist solely of a sampling decision, with no traceid or spanid values. There are...
Read more >Sampling for ASP.NET
If TracesSampler is defined, its decision will be used. It can choose to keep or ignore any parent sampling decision, use the sampling...
Read more >sentry - Go Packages
A SamplingContext is passed to a TracesSampler to determine a sampling decision. TODO(tracing): possibly expand SamplingContext to include custom / user- ...
Read more >Technical distributed tracing details
Technical details of New Relic's distributed tracing, including limits, explanation of sampling, trace data structure, and trace storage.
Read more >sentry/types@7.62.0
Function to compute tracing sample rate dynamically and filter unwanted traces. Tracing is enabled if either this or tracesSampleRate is defined. If both...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
OK. Then nothing to do here. Closing as works as designed. Thanks for the clarity.
The background story on why the sampler callback always runs (even if the sentry-trace has a sampled transaction) is that otherwise there’s no way for a backend to control the volume if it gets overwhelmed by incoming transactions initiated by a front end. That said, I agree it’s a pitfall, and the only thing done, to my knowledge, to hedge the risk of users falling into this issue, was to add to our docs in all sample code snippets that users should peek into the parent sampling decision if they care about that, examples:
More context: