Skip to content

Conversation

@xiang17
Copy link
Contributor

@xiang17 xiang17 commented Dec 2, 2025

Fixes #3395.

OTEL_RESOURCE_ATTRIBUTES environment variable should follow format of W3C Baggage: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#specifying-resource-information-via-an-environment-variable

W3C Baggage value definition: https://www.w3.org/TR/baggage/#value

Any code points outside of the baggage-octet range MUST be percent-encoded. The percent code point (U+0025) MUST be percent-encoded.

Note, value MAY contain any number of the equal sign (U+003D) code points. Parsers MUST NOT assume that the equal sign is only used to separate key and value.

Changes

Please provide a brief description of the changes here.

  • Decode percent-encoded value in OTEL_RESOURCE_ATTRIBUTES.
  • Treat only the first equal sign (=) as key-value separator. The rest are part of value.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • [ ] Changes in public API reviewed (if applicable)

@xiang17 xiang17 requested a review from a team as a code owner December 2, 2025 18:56
@github-actions github-actions bot added the pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package label Dec 2, 2025
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.88%. Comparing base (f630c55) to head (c35f63e).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #6737   +/-   ##
=======================================
  Coverage   86.88%   86.88%           
=======================================
  Files         259      259           
  Lines       12066    12068    +2     
=======================================
+ Hits        10483    10485    +2     
  Misses       1583     1583           
Flag Coverage Δ
unittests-Project-Experimental 86.72% <100.00%> (-0.07%) ⬇️
unittests-Project-Stable 86.64% <100.00%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...OpenTelemetry/Resources/OtelEnvResourceDetector.cs 100.00% <100.00%> (ø)

@xiang17 xiang17 changed the title Fix env var parsing spec gap for OTEL_RESOURCE_ATTRIBUTES Decode value in OTEL_RESOURCE_ATTRIBUTES environment variable Dec 2, 2025
@rajkumar-rangaraj
Copy link
Member

how is this different from #6461

@xiang17
Copy link
Contributor Author

xiang17 commented Dec 2, 2025

how is this different from #6461

The biggest difference is that this is not in the hot path. This PR is simply a bug fix for OTEL_RESOURCE_ATTRIBUTES.

The functionality is covered in that PR if that goes through. However, that one is in the hot path (baggage propagation) and needs lots of scrutiny.

That one also validates key and value doesn't contain invalid characters.

Copy link
Member

@rajkumar-rangaraj rajkumar-rangaraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rajkumar-rangaraj rajkumar-rangaraj added this pull request to the merge queue Dec 5, 2025
Merged via the queue into open-telemetry:main with commit a338c96 Dec 5, 2025
63 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

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

This was referenced Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OTEL_RESOURCE_ATTRIBUTES values are not parsed as defined per spec

2 participants