Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Maple review🟢 Confidence 4/5 · likely safe to merge Gzips all four OTLP exporters and head-samples the gateway's own traces through a new
Findings🔵 Note · F1 ·
|
The gateway (service.name=ingest) emits ~4.6M spans/hour of its own traces, ~7 per request at ~650k req/h and 13x every other Maple service combined, all exported to the in-VPC collector as uncompressed OTLP/HTTP protobuf. All four OTLP exporters (traces, logs, operational and usage metrics) now gzip. Traces are head-sampled by a ParentBased(TraceIdRatioBased) sampler at INGEST_SELF_TRACE_SAMPLE_RATIO, in (0, 1] with a default of 1.0; an invalid value refuses to boot. When the ratio is below 1 every sampled span carries SampleRate = 1/ratio, so Maple's weighted throughput still counts every request. Logs and metrics stay unsampled. prd sets the ratio to 0.05 via resolveIngestSelfTraceSampleRatio; previews keep the default.
…PLE_RATIO The gateway now builds its sampler explicitly, so OTEL_TRACES_SAMPLER and _ARG no longer apply to it.
334defd to
de19115
Compare
Maple review🟢 Confidence 4/5 · likely safe to merge The gateway's four OTLP exporters now gzip, and its own traces are head-sampled by a new
Fixed since the last review
What was checked
|
Stacked on #1213.
Problem
The gateway traces 100% of its own requests and exports them as uncompressed OTLP/HTTP protobuf. In prd that's ~4.6M spans/hour (~7 spans per request), about 13x every other Maple service combined. It costs cross-AZ transfer to the in-VPC collector, collector CPU, the collector's uploads, and warehouse ingestion and storage for the internal org.
Change
gzip-httpfeature.INGEST_SELF_TRACE_SAMPLE_RATIO(default 1.0; anything outside (0, 1] refuses to boot).SelfTraceSamplerwrapsParentBased(TraceIdRatioBased). When the ratio is below 1 it stampsSampleRate = 1/ratioon every sampled span, so the warehouse'sSampleRateweighting (docs/sampling-throughput.md) keeps throughput and request counts right.resolveIngestSelfTraceSampleRatio(stage); previews stay at 1.0. Logs and metrics are not sampled.Alert check
At 5%, prd keeps ~39k gateway spans per 10 min, so "Ingest gateway silent" (count < 500) and "Ingest pipeline stopped" (count < 1000) keep a wide margin. Both use
count(); switching them tosum(SampleRate)would make them sampling-proof.Tests
self_trace_sample_ratio_must_be_in_the_unit_intervalsampled_self_spans_carry_their_sample_rate: sampled root, dropped root, child of a sampled parent, and ratio 1.0 adds nothing.stage.test.tscase for the per-stage ratio.Notes
The gateway doesn't extract incoming trace context, so every root is local. If it ever starts honouring a caller's
traceparent,ParentBasedwould follow the caller's sampled flag and the stampedSampleRatewould be wrong.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.