Skip to content

perf: Do not allocate for scope attributes that collide with reserved ones#3548

Merged
cijothomas merged 2 commits into
open-telemetry:mainfrom
ArthurSens:remove-allocation
Jun 10, 2026
Merged

perf: Do not allocate for scope attributes that collide with reserved ones#3548
cijothomas merged 2 commits into
open-telemetry:mainfrom
ArthurSens:remove-allocation

Conversation

@ArthurSens

Copy link
Copy Markdown
Member

Follow up from #3503 (comment)

Changes

Prevent allocation in format! for labels that we know will collide with reserved ones.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
@ArthurSens ArthurSens requested a review from a team as a code owner June 10, 2026 17:18
Comment on lines 430 to 432
if RESERVED_SCOPE_LABELS.contains(&label_name.as_str()) {
continue;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I considered removing this, but if we get something like schema-url, it will become schema_url after sanitization, and we need to drop it as well.

Is there a way that we can avoid allocation when they match a regex? I assume not, since regex is usually more resource-intensive than an exact match...?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

agreed. this PR is good as-is.

@ArthurSens ArthurSens changed the title Do not allocate for scope attributes that collide with reserved ones perf: Do not allocate for scope attributes that collide with reserved ones Jun 10, 2026
@cijothomas cijothomas enabled auto-merge June 10, 2026 17:31
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.8%. Comparing base (874633d) to head (6c5460e).

Files with missing lines Patch % Lines
opentelemetry-prometheus/src/lib.rs 0.0% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3548     +/-   ##
=======================================
- Coverage   82.8%   82.8%   -0.1%     
=======================================
  Files        130     130             
  Lines      27353   27356      +3     
=======================================
  Hits       22675   22675             
- Misses      4678    4681      +3     

☔ 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.

@cijothomas cijothomas added this pull request to the merge queue Jun 10, 2026
Merged via the queue into open-telemetry:main with commit 3e12c94 Jun 10, 2026
27 of 28 checks passed
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.

2 participants