Skip to content

sdk/trace: treat empty sampler env values as unset - #8873

Open
RedZapdos123 wants to merge 3 commits into
open-telemetry:mainfrom
RedZapdos123:sdk-trace-empty-sampler-env
Open

sdk/trace: treat empty sampler env values as unset#8873
RedZapdos123 wants to merge 3 commits into
open-telemetry:mainfrom
RedZapdos123:sdk-trace-empty-sampler-env

Conversation

@RedZapdos123

@RedZapdos123 RedZapdos123 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description:

Issue #8870 reported that empty OTEL_TRACES_SAMPLER and OTEL_TRACES_SAMPLER_ARG values were not treated the same as unset values in sdk/trace.

Current main still fell back to the effective default sampler behavior but it also emitted configuration errors for empty values because sampler env parsing treated empty strings as present values.

This PR treats trimmed empty sampler env values as unset and adds regression tests covering empty OTEL_TRACES_SAMPLER and empty OTEL_TRACES_SAMPLER_ARG values.

Closes #8870.

Verifications:

  • cd sdk/trace && go test . -run "TestTracerProviderSamplerConfigFromEnv(EmptyValues)?$" -count=1 -v.
  • cd sdk/trace && go test . -count=1.
  • cd sdk/trace && go test ./... -count=1.

Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.4%. Comparing base (1ad6638) to head (fed1604).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8873   +/-   ##
=====================================
  Coverage   88.4%   88.4%           
=====================================
  Files        331     331           
  Lines      21001   21000    -1     
=====================================
+ Hits       18572   18577    +5     
+ Misses      2429    2423    -6     
Files with missing lines Coverage Δ
sdk/trace/sampler_env.go 93.1% <100.0%> (-0.3%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
…pler-env

Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>

# Conflicts:
#	CHANGELOG.md
@MrAlias MrAlias added this to the v1.47.0 milestone Aug 31, 2026
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.

sdk/trace: empty OTEL_TRACES_SAMPLER* values are not treated as unset

3 participants