feat(configuration): add sampler parsing#6409
Merged
maryliag merged 16 commits intoopen-telemetry:mainfrom Mar 13, 2026
Merged
Conversation
- Add type models: ProbabilitySampler, CompositeSampler, RuleBasedSampler - Implement YAML sampler parsing in FileConfigFactory.parseSampler() - Implement env var parsing (OTEL_TRACES_SAMPLER, OTEL_TRACES_SAMPLER_ARG) - Add tests for always_on, always_off, traceidratio, parentbased samplers - Support probability/development and composite/development sampler types Fixes open-telemetry#6290
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6409 +/- ##
==========================================
- Coverage 95.74% 95.74% -0.01%
==========================================
Files 364 364
Lines 11871 11972 +101
Branches 2789 2828 +39
==========================================
+ Hits 11366 11462 +96
- Misses 505 510 +5
🚀 New features to boost your workflow:
|
- Convert null values to undefined for always_on/always_off samplers - Ensures consistent behavior with existing defaults - YAML 'always_on:' (no value) → undefined, matching initializeDefaultTracerProviderConfiguration() Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add probability sampler type (non-development) - Make CompositeSampler.samplers optional - Expand RuleBasedSamplerRule with full spec fields - Recursively parse samplers in rule_based rules - Update kitchen-sink test expectations
- Add unknown sampler type warning test - Add parentbased_always_off env var test - Add composite sampler with samplers array test - Add composite sampler with rule_based full features test - Coverage: EnvironmentConfigFactory 98.89%, FileConfigFactory 99.82%
maryliag
reviewed
Mar 2, 2026
Member
Author
|
Thank you for the review @maryliag and sorry for the delay getting back to you sooner. I'll work through your feedback and get back to you ASAP. |
maryliag
reviewed
Mar 3, 2026
Contributor
maryliag
left a comment
There was a problem hiding this comment.
thank you for the changes, just a small nit
maryliag
approved these changes
Mar 3, 2026
Assisted-by: Claude Sonnet 4.6
trentm
reviewed
Mar 9, 2026
…ILE env var Upstream main renamed OTEL_EXPERIMENTAL_CONFIG_FILE to OTEL_CONFIG_FILE in open-telemetry#6486, but the new sampler parsing tests still referenced the old name. Assisted-by: Claude Sonnet 4.6
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.
Which problem is this PR solving?
Fixes #6290
RC3 spec requires sampler configuration via YAML files and environment variables. Currently missing:
probability/developmentandcomposite/developmentsamplersNote:
jaeger_remote/developmentis not included as it is an SDK extension plugin (per the spec'sisSdkExtensionPlugin: trueannotation on theSamplertype) and is expected to be provided via a third-party extension rather than implemented natively. This is consistent with the Java SDK's approach.Short description of the changes
Type Models (tracerProviderModel.ts):
ExperimentalProbabilitySamplerinterface (matching spec name)ExperimentalComposableSampler,ExperimentalComposableRuleBasedSampler,ExperimentalComposableRuleBasedSamplerRule,ExperimentalComposableParentThresholdSampler,ExperimentalComposableProbabilitySamplerinterfacesSamplerunion withprobability/developmentandcomposite/developmentYAML Parsing (FileConfigFactory.ts):
parseSampler()function supporting all sampler typesparseComposableSampler()helper forExperimentalComposableSamplertypesparent_based.root, rule-based rules, etc.)setTracerProvider()Environment Variable Parsing (EnvironmentConfigFactory.ts):
setSampler()function (called from withinsetTracerProvider()) supporting:always_on,always_off,traceidratioparentbased_always_on,parentbased_always_off,parentbased_traceidratioOTEL_TRACES_SAMPLER_ARGfor ratio valuesTests:
always_on,always_off,traceidratio,parentbased_always_on,parentbased_always_off,parentbased_traceidratio, unknown sampler warningsamplers.yaml(parent_based with probability/development),composite-sampler-array.yaml(rule_based with multiple rules),composite-sampler-rulebased-full.yaml(rule_based with attribute matching)Type of change
How Has This Been Tested?
Checklist: