-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent setting a probabilistic decision maker for OTLP spans sampled by the Error Sampler #33586
Conversation
Test changes on VMUse this command from test-infra-definitions to manually test this PR changes on a VM: inv aws.create-vm --pipeline-id=54641452 --os-family=ubuntu Note: This applies to commit 21d947b |
Uncompressed package size comparisonComparison with ancestor Diff per package
Decision✅ Passed |
Regression DetectorRegression Detector ResultsMetrics dashboard Baseline: 91794f6 Optimization Goals: ✅ No significant changes detected
|
perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
---|---|---|---|---|---|---|
➖ | quality_gate_logs | % cpu utilization | +2.00 | [-1.10, +5.09] | 1 | Logs |
➖ | uds_dogstatsd_to_api_cpu | % cpu utilization | +1.48 | [+0.60, +2.37] | 1 | Logs |
➖ | file_to_blackhole_1000ms_latency | egress throughput | +0.33 | [-0.45, +1.11] | 1 | Logs |
➖ | quality_gate_idle_all_features | memory utilization | +0.30 | [+0.24, +0.36] | 1 | Logs bounds checks dashboard |
➖ | file_to_blackhole_500ms_latency | egress throughput | +0.12 | [-0.66, +0.89] | 1 | Logs |
➖ | file_to_blackhole_0ms_latency | egress throughput | +0.01 | [-0.87, +0.90] | 1 | Logs |
➖ | file_to_blackhole_300ms_latency | egress throughput | +0.00 | [-0.64, +0.64] | 1 | Logs |
➖ | file_to_blackhole_0ms_latency_http2 | egress throughput | -0.00 | [-0.78, +0.78] | 1 | Logs |
➖ | uds_dogstatsd_to_api | ingress throughput | -0.00 | [-0.29, +0.28] | 1 | Logs |
➖ | tcp_dd_logs_filter_exclude | ingress throughput | -0.00 | [-0.02, +0.01] | 1 | Logs |
➖ | file_to_blackhole_0ms_latency_http1 | egress throughput | -0.02 | [-0.84, +0.80] | 1 | Logs |
➖ | file_to_blackhole_100ms_latency | egress throughput | -0.02 | [-0.74, +0.69] | 1 | Logs |
➖ | file_to_blackhole_1000ms_latency_linear_load | egress throughput | -0.16 | [-0.64, +0.31] | 1 | Logs |
➖ | quality_gate_idle | memory utilization | -0.37 | [-0.42, -0.33] | 1 | Logs bounds checks dashboard |
➖ | file_tree | memory utilization | -0.77 | [-0.84, -0.71] | 1 | Logs |
➖ | tcp_syslog_to_blackhole | ingress throughput | -1.01 | [-1.09, -0.94] | 1 | Logs |
Bounds Checks: ✅ Passed
perf | experiment | bounds_check_name | replicates_passed | links |
---|---|---|---|---|
✅ | file_to_blackhole_0ms_latency | lost_bytes | 10/10 | |
✅ | file_to_blackhole_0ms_latency | memory_usage | 10/10 | |
✅ | file_to_blackhole_0ms_latency_http1 | lost_bytes | 10/10 | |
✅ | file_to_blackhole_0ms_latency_http1 | memory_usage | 10/10 | |
✅ | file_to_blackhole_0ms_latency_http2 | lost_bytes | 10/10 | |
✅ | file_to_blackhole_0ms_latency_http2 | memory_usage | 10/10 | |
✅ | file_to_blackhole_1000ms_latency | memory_usage | 10/10 | |
✅ | file_to_blackhole_1000ms_latency_linear_load | memory_usage | 10/10 | |
✅ | file_to_blackhole_100ms_latency | lost_bytes | 10/10 | |
✅ | file_to_blackhole_100ms_latency | memory_usage | 10/10 | |
✅ | file_to_blackhole_300ms_latency | lost_bytes | 10/10 | |
✅ | file_to_blackhole_300ms_latency | memory_usage | 10/10 | |
✅ | file_to_blackhole_500ms_latency | lost_bytes | 10/10 | |
✅ | file_to_blackhole_500ms_latency | memory_usage | 10/10 | |
✅ | quality_gate_idle | intake_connections | 10/10 | bounds checks dashboard |
✅ | quality_gate_idle | memory_usage | 10/10 | bounds checks dashboard |
✅ | quality_gate_idle_all_features | intake_connections | 10/10 | bounds checks dashboard |
✅ | quality_gate_idle_all_features | memory_usage | 10/10 | bounds checks dashboard |
✅ | quality_gate_logs | intake_connections | 10/10 | |
✅ | quality_gate_logs | lost_bytes | 10/10 | |
✅ | quality_gate_logs | memory_usage | 10/10 |
Explanation
Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%
Performance changes are noted in the perf column of each table:
- ✅ = significantly better comparison variant performance
- ❌ = significantly worse comparison variant performance
- ➖ = no significant change in performance
A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".
For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:
-
Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.
-
Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.
-
Its configuration does not mark it "erratic".
CI Pass/Fail Decision
✅ Passed. All Quality Gates passed.
- quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
a720121
to
6121815
Compare
ingestion_reason:probabilistic
always for OTLP error spans
6121815
to
ee1c2e6
Compare
ingestion_reason:probabilistic
always for OTLP error spansingestion_reason:error
instead ofingestion_reason:probabilistic
when an OTLP span is sampled by Error Sampler
9e464b4
to
f60d478
Compare
f60d478
to
8974346
Compare
ingestion_reason:error
instead ofingestion_reason:probabilistic
when an OTLP span is sampled by Error SamplerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval for OTel
releasenotes/notes/fix-ingestion-reason-for-otlp-spans-71a29c0ffb8f7ade.yaml
Outdated
Show resolved
Hide resolved
e2988ef
to
21d947b
Compare
## If `apm_config.probabilistic_sampler.enabled` is enabled, this config is ignored, `apm_config.probabilistic_sampler.enabled.sampling_percentage` | ||
## is used instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behavior has existed before, but it has now been explicitly documented. cc @ajgajg1134
ProbabilisticSampler is not affected by SamplingPriority of OTLPReceiver’s probabilistic sampler decision.
datadog-agent/pkg/trace/agent/agent.go
Lines 653 to 665 in 91794f6
if a.conf.ProbabilisticSamplerEnabled { | |
if rare { | |
return true, true | |
} | |
if a.ProbabilisticSampler.Sample(pt.Root) { | |
pt.TraceChunk.Tags[tagDecisionMaker] = probabilitySampling | |
return true, true | |
} | |
if traceContainsError(pt.TraceChunk.Spans, false) { | |
return a.ErrorsSampler.Sample(now, pt.TraceChunk.Spans, pt.Root, pt.TracerEnv), true | |
} | |
return false, true | |
} |
datadog-agent/pkg/trace/sampler/probabilistic.go
Lines 113 to 168 in dcd0631
// Sample a trace given the chunk's root span, returns true if the trace should be kept | |
func (ps *ProbabilisticSampler) Sample(root *trace.Span) (sampled bool) { | |
if !ps.enabled { | |
return false | |
} | |
defer func() { | |
ps.metrics.record(sampled, newMetricsKey(root.Service, "", nil)) | |
}() | |
tid := make([]byte, 16) | |
var err error | |
if !ps.fullTraceIDMode { | |
binary.BigEndian.PutUint64(tid, root.TraceID) | |
} else { | |
tid, err = get128BitTraceID(root) | |
} | |
if err != nil { | |
log.Errorf("Unable to probabilistically sample, failed to determine 128-bit trace ID from incoming span: %v", err) | |
return false | |
} | |
hasher := fnv.New32a() | |
_, _ = hasher.Write(ps.hashSeed) | |
_, _ = hasher.Write(tid) | |
hash := hasher.Sum32() | |
keep := hash&bitMaskHashBuckets < ps.scaledSamplingPercentage | |
if keep { | |
sampled = true | |
setMetric(root, probRateKey, ps.samplingPercentage) | |
} | |
return | |
} | |
func get128BitTraceID(span *trace.Span) ([]byte, error) { | |
// If it's an otel span the whole trace ID is in otel.trace | |
if tid, ok := span.Meta["otel.trace_id"]; ok { | |
bs, err := hex.DecodeString(tid) | |
if err != nil { | |
return nil, err | |
} | |
return bs, nil | |
} | |
tid := make([]byte, 16) | |
binary.BigEndian.PutUint64(tid[8:], span.TraceID) | |
// Get hex encoded upper bits for datadog spans | |
// If no value is found we can use the default `0` value as that's what will have been propagated | |
if upper, ok := span.Meta["_dd.p.tid"]; ok { | |
u, err := strconv.ParseUint(upper, 16, 64) | |
if err != nil { | |
return nil, err | |
} | |
binary.BigEndian.PutUint64(tid[:8], u) | |
} | |
return tid, nil | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For info, we now have the IsConfigured
function in the config to know if a setting was set by the user or comes from the defaults.
/merge |
Devflow running:
|
What does this PR do?
When Error Sampler works, avoid setting neither
_dd.p.dm:-4
or_dd.p.dm:-9
to prevent from applyingingestion_reason:probabilistic
to OTLP errors.Motivation
OTLP error spans always have
ingestion_reason:probabilistic
. It should beingestion_reason:error
when Error Sampler works.Describe how you validated your changes
For testing, send OTLP error spans from Python with OTel SDK every 10 milliseconds.
We can see transition from
ingestion_reason:probabilistic
toingestion_reason:error
after this PR.Tested with two patterns.
DD_OTLP_CONFIG_TRACES_PROBABILISTIC_SAMPLER_SAMPLING_PERCENTAGE=1
to run Error Sampler easily.DD_APM_PROBABILISTIC_SAMPLER_ENABLED=true
andDD_APM_PROBABILISTIC_SAMPLER_PERCENTAGE=0
docker-compose.yaml and Python app
span in JSON before PR
span in JSON after PR
Possible Drawbacks / Trade-offs
Additional Notes
Pattern 1
datadog-agent/pkg/trace/agent/agent.go
Lines 690 to 700 in 91794f6
Pattern 2
datadog-agent/pkg/trace/agent/agent.go
Lines 653 to 665 in 91794f6