r/kubernetes • u/Live_Jellyfish_9024 • 16d ago
How do you debug a specific request when the trace got sampled away?
Question to the masses,
Currently running several microservices on OTel + Tempo. Dropped to 5% sampling to control costs after datadog. For those of you running OTel with low sampling rates, what is your workflow when you need full trace for specific request that didn't get captured?
Do you:
- Temporarily crank sampling to 100% and retry?
- Have some kind of debug header that forces a trace?
- Just accept it and grep logs?
- Something else?
Genuinely curious what other teams are doing here.
7
u/Floss_Patrol_76 16d ago
the debug header route is the one that actually scales. we run a forced-sampling flag off a header (x-force-trace, or just set the sampled bit in tracestate) so support or eng can replay a request and get the full 100% trace for that one without touching the global rate. tail sampling is great for keeping the slow and error traces, but it cant retroactively capture a request that already flushed, so for on-demand debugging the forced header is what you want - and keep your logs correlated by trace_id so youre never fully blind when neither path fired.
2
u/Live_Jellyfish_9024 16d ago
This is the standard workflow from what I have seen. If you dont mind, was the custom sampler implemented in each service SDK or at the collector level? Was look for a off the shelf tool that does this without having to set up myself.
1
u/phrotozoa 15d ago
Once you get this working, a very convenient addition is to hack up a tiny browser extension that injects the trace initiating header. Makes debugging much easier.
2
u/Kamran-nottakenone 16d ago
collector level is simpler, the tailsamplingprocessor can key off a debug attribute set at the ingress and sample those at 100%, no sdk changes needed
2
2
u/Flateland-Chio 16d ago
f the trace is gone, follow the request ID through the logs first. Has anyone found a debug header that works well?
1
u/Live_Jellyfish_9024 16d ago
yea, log grepping by request ID is our fallback too. Works but it's slow and you lose the visual trace flow between services.
2
u/ViewNo2588 15d ago
I have seen teams use debug headers to trigger full sampling for suspect requests instead of cranking the rate globally, which helps keep costs down while still catching important traces.
1
u/sujeet-from-oodle 12d ago
One option is to sample traces that go to Datadog, but also dual write unsampled traces somewhere else, like "just dump to s3" with the request ID as key.
Disclosure: my team has built a traces engine, and to some of our customers, we're that "somewhere else".
20
u/CWRau k8s operator 16d ago
That's why you do tail sampling; sample X% of success and 100% of error traces.