Skip to content

Match environment variables for config keys containing underscores - #8933

Merged
jack-berg merged 2 commits into
open-telemetry:mainfrom
thswlsqls:fix/configutil-env-var-underscore-keys
Oct 15, 2026
Merged

jack-berg merged 2 commits into
open-telemetry:mainfrom
thswlsqls:fix/configutil-env-var-underscore-keys

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #8932

Description

  • ConfigUtil.getString normalized the lookup key with normalizePropertyKey (keeps _) but env var names with normalizeEnvironmentVariableKey (turns _ into .), so keys containing _ never matched an env var.
  • So OTEL_EXPERIMENTAL_SDK_JVM_STACKTRACE=true was ignored, while the system property otel.experimental.sdk.jvm_stacktrace worked.
  • Normalize the lookup key with normalizeEnvironmentVariableKey before comparing it with env var names. Keys without _ behave the same as before.
  • System property matching and priority are unchanged.
  • Updated the getString Javadoc to match.

Testing done

  • Added a config_key assertion to ConfigUtilTest#getString_EnvironmentVariable (the build sets CONFIG_KEY=environment). It fails without the fix ("default") and passes with it.
  • ./gradlew :common:check passed (9 tests).
  • ./gradlew :sdk:common:test passed (346 tests).

@thswlsqls
thswlsqls marked this pull request as ready for review October 12, 2026 02:13
@thswlsqls
thswlsqls requested a review from a team as a code owner October 12, 2026 02:13
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-15 21:51 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.66%. Comparing base (387f5c5) to head (52cb353).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8933   +/-   ##
=========================================
  Coverage     90.65%   90.66%           
- Complexity    10887    10888    +1     
=========================================
  Files          1015     1015           
  Lines         29731    29733    +2     
  Branches       3876     3876           
=========================================
+ Hits          26953    26956    +3     
  Misses         1860     1860           
+ Partials        918      917    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

Comment thread common/src/main/java/io/opentelemetry/common/impl/ConfigUtil.java
Show that a key with an underscore, such as
otel.experimental.sdk.jvm_stacktrace, matches the environment variable
OTEL_EXPERIMENTAL_SDK_JVM_STACKTRACE. Requested in review. Javadoc only,
no behavior change.

Generated-by: Claude Code
@jack-berg
jack-berg merged commit 66848a0 into open-telemetry:main Oct 15, 2026
34 checks passed
@otelbot

otelbot Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @thswlsqls! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

@thswlsqls
thswlsqls deleted the fix/configutil-env-var-underscore-keys branch October 18, 2026 12:28
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.

Environment variables are ignored for config keys containing underscores

3 participants