[APMSVLS-469] feat(traces): rescue errored traces via agent-side error sampler - #1320
Draft
lucaspimentel wants to merge 5 commits into
Draft
[APMSVLS-469] feat(traces): rescue errored traces via agent-side error sampler#1320lucaspimentel wants to merge 5 commits into
lucaspimentel wants to merge 5 commits into
Conversation
On the lambda_extension_compute_stats path, the extension drops every trace marked P0 (priority <= 0) after computing its stats. This adds an error sampler that gives those dropped traces a second look: errored traces are kept (rescued) up to DD_APM_ERROR_TPS traces/sec (default 10), distributed fairly across trace signatures, with _dd.errors_sr stamped on the rescued root span. Non-errored P0 traces are still dropped, and stats still count all traces. This guarantees error visibility even under aggressive sampling. Ports the Go trace agent's ScoreSampler/ErrorTPS behavior via the shared, dependency-free datadog-agent-trace-sampler crate. New config: - DD_APM_ERROR_TPS (default 10.0; 0 disables the rescue) - DD_APM_EXTRA_SAMPLE_RATE (default 1.0) 🤖
|
Errored traces were only rescued from a drop decision when the root span itself carried the error, so a trace whose failure happened deeper (for example a failed downstream call that the handler caught) was still dropped. Now an error anywhere in the trace makes it a rescue candidate, matching the Datadog Agent. 🤖
Traces dropped on purpose, either by a tracer sampling rule or by an explicit MANUAL_DROP, were being fed to the error sampler and could be sent to Datadog anyway when they contained an error. Only traces dropped by automatic sampling are now rescue candidates, matching the Datadog Agent. 🤖
The error sampler's per-signature rate limits were keyed on the extension's own DD_ENV, so when that was unset every trace shared one empty env and distinct services competed for the same budget. The env the tracer reported with the trace is now used instead, matching the Datadog Agent. 🤖
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
On the
lambda_extension_compute_statspath, the extension drops every trace marked P0 (priority <= 0) after computing its stats. That means an errored trace sampled away by the tracer is invisible in the UI, even though its stats are counted.This adds an agent-side error sampler that gives those dropped traces a second look: errored traces are rescued up to
DD_APM_ERROR_TPStraces/sec (default 10), distributed fairly across trace signatures, with_dd.errors_srstamped on the rescued root span. The result is guaranteed error visibility even under aggressive sampling, matching the Go trace agent'sScoreSampler/ErrorTPSbehavior.Which traces are candidates, matching the Go agent:
MANUAL_DROP, are honored and never rescued.The sampling logic itself lives in the shared, dependency-free
datadog-agent-trace-samplercrate added in DataDog/serverless-components#141. It takes primitives in (SpanView/TraceView) and returns aSampleDecision, exposing no protobufSpantype, so consumers pinning different libdatadog revisions can share it.New configuration:
DD_APM_ERROR_TPS10.00disables the rescue. Go agent equivalent:apm_config.errors_per_second.DD_APM_EXTRA_SAMPLE_RATE1.0apm_config.extra_sample_rate.Both are flat env/YAML keys (
apm_error_tps,apm_extra_sample_rate), unlike the Go agent's nestedapm_config.*form.Blocked on
DataDog/serverless-components#141 must merge first. The four serverless-components pins in
bottlecap/Cargo.tomlcurrently point at that PR's branch rev (3759fae) and need to be repinned to the mergedmainrev before this can land. Draft until then.Testing
test_error_sampler_rescues_errored_p0_chunksintraces/trace_processor.rs: an errored auto-dropped chunk is rescued and stamped with_dd.errors_sr; a non-errored one is still dropped; an errored chunk marked as an explicit user drop is not rescued.test_error_sampler_rescues_chunk_with_errored_child_span: a trace whose root is fine but whose child span errored is still rescued.apm_integration_test.rswires the sampler into the processor pipeline, so the existing end-to-end APM assertions run with it enabled.cargo test --workspace— 564 passed, 0 failed.cargo clippy --workspace --all-targets --features defaultandcargo fmt --all -- --checkclean.🤖