Skip to content

feat(configuration): add sampler parsing#6409

Open
MikeGoldsmith wants to merge 8 commits intoopen-telemetry:mainfrom
honeycombio:mike/parse-samplers
Open

feat(configuration): add sampler parsing#6409
MikeGoldsmith wants to merge 8 commits intoopen-telemetry:mainfrom
honeycombio:mike/parse-samplers

Conversation

@MikeGoldsmith
Copy link
Member

Which problem is this PR solving?

Fixes #6290

RC3 spec requires sampler configuration via YAML files and environment variables. Currently missing:

  • Type models for probability/development and composite/development samplers
  • YAML sampler parsing in FileConfigFactory
  • Environment variable sampler parsing (OTEL_TRACES_SAMPLER, OTEL_TRACES_SAMPLER_ARG)

Short description of the changes

Type Models (tracerProviderModel.ts):

  • Added ProbabilitySampler, CompositeSampler, RuleBasedSampler interfaces
  • Extended Sampler union with probability/development and composite/development

YAML Parsing (FileConfigFactory.ts):

  • Added parseSampler() function supporting all sampler types
  • Recursive parsing for nested samplers (parent_based.root, etc.)
  • Integrated into setTracerProvider()

Environment Variable Parsing (EnvironmentConfigFactory.ts):

  • Added setSampler() function supporting:
    • always_on, always_off, traceidratio
    • parentbased_always_on, parentbased_always_off, parentbased_traceidratio
  • Parses OTEL_TRACES_SAMPLER_ARG for ratio values

Tests:

  • 5 new env var sampler tests
  • 1 YAML fixture test (samplers.yaml)
  • Validates all basic and parent-based sampler types

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Unit tests for env var sampler parsing (always_on, always_off, traceidratio, parentbased variants)
  • Integration test for YAML sampler parsing
  • Existing kitchen-sink.yaml includes complex sampler configurations

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated (CHANGELOG)

- 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
@MikeGoldsmith MikeGoldsmith requested a review from a team as a code owner February 13, 2026 15:11
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.62%. Comparing base (34e7d91) to head (11956e5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6409      +/-   ##
==========================================
+ Coverage   95.59%   95.62%   +0.03%     
==========================================
  Files         361      361              
  Lines       11595    11688      +93     
  Branches     2683     2719      +36     
==========================================
+ Hits        11084    11177      +93     
  Misses        511      511              
Files with missing lines Coverage Δ
...ages/configuration/src/EnvironmentConfigFactory.ts 99.54% <100.00%> (+0.03%) ⬆️
...al/packages/configuration/src/FileConfigFactory.ts 97.79% <100.00%> (+0.21%) ⬆️
...es/configuration/src/models/tracerProviderModel.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

MikeGoldsmith and others added 6 commits February 13, 2026 16:33
- 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%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

configuration package should parse tracer provider > sampler

1 participant

Comments