Skip to content

opentelemetry-api: improve performance of tracestate parsing - #5746

Merged
herin049 merged 3 commits into
open-telemetry:mainfrom
herin049:perf/improve-tracestate-parsing
Oct 6, 2026
Merged

herin049 merged 3 commits into
open-telemetry:mainfrom
herin049:perf/improve-tracestate-parsing

Conversation

@herin049

@herin049 herin049 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Description

Improves the performance of trace state parsing.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

uv run tox -e py314-test-opentelemetry-api

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

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

@herin049
herin049 requested a review from a team as a code owner October 5, 2026 18:50
@opentelemetry-pr-dashboard

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

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-06 00:49 UTC

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation is focused, preserves parsing behavior, and includes appropriate regression and boundary tests.

Review effort: Balanced
Findings: None

What changed in this PR

Improves tracestate parsing performance and limits oversized propagated headers.

Changes:

  • Replaces regex splitting with linear comma splitting and whitespace trimming.
  • Rejects combined tracestate headers exceeding 8192 characters.
  • Adds whitespace, performance, and size-boundary tests.
File Description
.changelog/​5746.fixed Documents the parsing fix and size limit.
opentelemetry-api/​src/​opentelemetry/​trace/​span.py Optimizes member parsing.
opentelemetry-api/​src/​opentelemetry/​trace/​propagation/​tracecontext.py Enforces the combined header-length limit.
opentelemetry-api/​tests/​trace/​test_tracestate.py Tests whitespace handling and parsing performance.
opentelemetry-api/​tests/​trace/​propagation/​test_tracecontexthttptextformat.py Tests length-limit boundaries.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread opentelemetry-api/src/opentelemetry/trace/span.py
@herin049
herin049 enabled auto-merge October 6, 2026 00:43
@herin049
herin049 added this pull request to the merge queue Oct 6, 2026
Merged via the queue into open-telemetry:main with commit 363f899 Oct 6, 2026
577 checks passed
@herin049
herin049 deleted the perf/improve-tracestate-parsing branch October 6, 2026 00:48
emdneto pushed a commit that referenced this pull request Oct 6, 2026
…5749)

* opentelemetry-api: improve performance of tracestate parsing

* add changelog fragment

* update optional whitespace comment

Co-authored-by: Lukas Hering <40302054+herin049@users.noreply.github.com>
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