Skip to content

feat(config): add shared _parse_headers helper for declarative config exporters#5021

Merged
xrmx merged 4 commits intoopen-telemetry:mainfrom
MikeGoldsmith:mike/config-common-helpers
Apr 1, 2026
Merged

feat(config): add shared _parse_headers helper for declarative config exporters#5021
xrmx merged 4 commits intoopen-telemetry:mainfrom
MikeGoldsmith:mike/config-common-helpers

Conversation

@MikeGoldsmith
Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith commented Mar 29, 2026

Description

Extracts _parse_headers — which merges an OTLP headers struct and a headers_list string into a single dict — into a new shared _common.py module.

This function is identical across the tracer, meter, and logger provider config PRs (#4985, #4987, #4990). Centralising it here means those PRs can import from _common rather than each defining their own copy, and keeps the logic in one place to test and maintain.

Note: this does not consolidate _parse_headers with _parse_attributes_list in _resource.py — they look similar but differ semantically: resource attributes are URL-decoded (urllib.parse.unquote), headers are not.

Type of change

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

How Has This Been Tested?

11 unit tests added in tests/_configuration/test_common.py covering:

  • both inputs None → returns None
  • headers_list parsing (single, multiple, whitespace, value-contains-=, malformed)
  • struct headers only (including None value → empty string)
  • struct headers take priority over headers_list for the same key

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

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

Assisted-by: Claude Sonnet 4.6

Extracts the header-merging logic that is duplicated across the tracer,
meter, and logger provider config modules into a single shared helper in
_common.py.  Subsequent provider PRs will import from here instead of
defining their own copy.

Assisted-by: Claude Sonnet 4.6
Assisted-by: Claude Sonnet 4.6
@MikeGoldsmith MikeGoldsmith moved this to Ready for review in Python PR digest Mar 30, 2026
@MikeGoldsmith MikeGoldsmith moved this from Ready for review to Approved PRs in Python PR digest Mar 30, 2026
@xrmx xrmx enabled auto-merge (squash) April 1, 2026 15:04
@xrmx xrmx merged commit 1362a75 into open-telemetry:main Apr 1, 2026
508 checks passed
@github-project-automation github-project-automation bot moved this from Approved PRs to Done in Python PR digest Apr 1, 2026
@MikeGoldsmith MikeGoldsmith deleted the mike/config-common-helpers branch April 2, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants