-
Notifications
You must be signed in to change notification settings - Fork 0
feat(sampling): datadog sampler #17
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
Conversation
2680189 to
7b61b31
Compare
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.
I'm only halfway through this, but here are some comments.
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.
Looks good AFAICT. Only nitpicks and performance questions.
6c296a9 to
361bb78
Compare
|
|
||
| /// Where this rule comes from (customer, dynamic, default) | ||
| #[serde(default = "default_provenance")] | ||
| pub provenance: String, |
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.
Should this be an enumeration if the values this can take is bounded?
Also where does this come from, can customer provide this?
This PR refactors the sampler a bit in order to store thre sampling decision in the TraceRegistry. The `ShouldSample` implementation is know in the datadog-opentelemetry crate, and the DatadogSampler uses simpler code. To test that this works, this PR adds integration tests with the test agent that create a new span, and send it. The snapshots should contain the expected sampling tags, and we check that the tracecontext contains expected keys.
datadog-opentelemetry/tests/snapshots/test_injection_extraction_tracestats.json
Show resolved
Hide resolved
|
Handling agent response is missing and Sampler configuration can be modified by agent (see TraceExporterWorker::handle_agent_reponse) Is it planned for another PR? |
Yes, the changes on this one are already big enough 😄 |
What does this PR do?
This PR adds the DatadogSampler, which has the following cap
Add DatadogSampler for intelligent trace sampling in dd-trace-rs
Summary
This PR adds a comprehensive sampling implementation for the Datadog tracer in Rust. The
DatadogSamplerprovides probabilistic and rule-based sampling capabilities to selectively record traces based on configurable criteria.Features
Implementation details
The implementation consists of several cooperating components:
DatadogSampler: The main sampler implementing OpenTelemetry'sShouldSampletraitSamplingRule: Configurable rules for matching spans and applying sampling decisionsRateSampler: Deterministic sampling based on trace ID hash valuesRateLimiter: Thread-safe limiting of sampling throughputGlobMatcher: Fast pattern matching with wildcard supportThe sampler is fully integrated with the Datadog OpenTelemetry tracer, which can be initialized with:
Testing
The implementation includes a comprehensive test suite covering all aspects of the sampler's behavior, including rule matching, sampling decisions, tag generation, and configuration loading.