Status Aware Error Sampling for OpenTelemetry#285
Open
vishalpolley-1mg wants to merge 4 commits into
Open
Conversation
…catalyst-core into feature/suspense-vite-fixes-v17
|
DeputyDev will no longer review pull requests automatically.To request a review, simply comment #review on your pull request—this will trigger an on-demand review whenever you need it. |
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.
Description
This PR implements Status Aware Error Sampling natively in the
catalyst-coreOpenTelemetry integration (src/otel.js).In high-throughput environments operating at low head-sampling rates (e.g. 1%), standard head-sampling discards 99% of all traces, resulting in the loss of 99% of error traces (4xx and 5xx). This feature introduces a two-stage sampling flow that defers the export decision until a request finishes, allowing the system to selectively promote and export error traces at independent rates (typically 100% for 5xx and 10% for 4xx) without inflating successful trace volume or incurring excessive memory overhead.
The implementation is fully backwards-compatible and operates as an opt-in feature under the
errorSamplingconfiguration block.Key Features & Components
1. Custom Sampler: StatusAwareSampler
RECORD(instead ofNOT_RECORD). This instructs the SDK to build spans in memory so they can be analyzed upon request completion.0–12(first 48 bits) of thetraceIdhex string to evaluate the head-sampling probability.2. Custom Processor: PromotingSpanProcessor
SAMPLEDbit set) straight to the internalBatchSpanProcessorto preserve standard low-latency batch exports.RECORDonly) in an in-memory Map keyed bytraceId.RATE_5XX(typically 100%). Evaluated using characters12–24of thetraceIdstring.RATE_4XX(excluding configured timeouts/gateway noise).traceIdsso that asynchronous child spans completing after the root span are still successfully exported.1024traces in the buffer to prevent OOM errors.Configuration Reference
You can activate the feature by passing the
errorSamplingblock toOtel.init:Testing & Verification Done
traceFlags: 1(SAMPLED), and exported to Jaeger.mwebanddwebapps, confirming successful traces are exported according to the sampling rate, while 4xx and 5xx errors are successfully promoted and tagged with the"promoted": trueattribute.