Skip to content

perf(sdk-metrics): optionally capture active context for sync instruments#6848

Merged
pichlermarc merged 3 commits into
open-telemetry:mainfrom
legendecas:attribute-processor-context
Jul 1, 2026
Merged

perf(sdk-metrics): optionally capture active context for sync instruments#6848
pichlermarc merged 3 commits into
open-telemetry:mainfrom
legendecas:attribute-processor-context

Conversation

@legendecas

@legendecas legendecas commented Jun 24, 2026

Copy link
Copy Markdown
Member

Which problem is this PR solving?

When no AttributesProcessor are registered, the context argument is not used.
This makes the context.active() optional unless there is an AttributesProcessor registered.

No impact on public APIs.

main:
Counter.add (fixed attributes) x 25,533,509 ops/sec ±0.81% (95 runs sampled)
Counter.add (varied attributes, 100 combos) x 24,512,358 ops/sec ±0.55% (98 runs sampled)

PR:
Counter.add (fixed attributes) x 30,876,145 ops/sec ±1.18% (91 runs sampled)
Counter.add (varied attributes, 100 combos) x 31,385,201 ops/sec ±0.83% (96 runs sampled)

+21%/+28%

Follow-up: replace noop AttributesProcessor with undefined to identify Views with no AttributesProcessor configured.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • New test on passing context to attribute processors.

Checklist:

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

Refs: #6100

@legendecas
legendecas requested a review from a team as a code owner June 24, 2026 20:39
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.58%. Comparing base (dddbc0e) to head (d5c460f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6848   +/-   ##
=======================================
  Coverage   95.58%   95.58%           
=======================================
  Files         388      388           
  Lines       13152    13163   +11     
  Branches     3001     3004    +3     
=======================================
+ Hits        12571    12582   +11     
  Misses        581      581           
Files with missing lines Coverage Δ
packages/sdk-metrics/src/Instruments.ts 96.07% <100.00%> (ø)
...ckages/sdk-metrics/src/state/AsyncMetricStorage.ts 100.00% <100.00%> (ø)
...ages/sdk-metrics/src/state/DeltaMetricProcessor.ts 100.00% <100.00%> (ø)
packages/sdk-metrics/src/state/MeterSharedState.ts 98.33% <ø> (-0.03%) ⬇️
...dk-metrics/src/state/MultiWritableMetricStorage.ts 100.00% <100.00%> (ø)
...ackages/sdk-metrics/src/state/SyncMetricStorage.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pichlermarc
pichlermarc added this pull request to the merge queue Jul 1, 2026
Merged via the queue into open-telemetry:main with commit d61ab5f Jul 1, 2026
29 of 31 checks passed
@legendecas
legendecas deleted the attribute-processor-context branch July 1, 2026 18:05
@otelbot-js otelbot-js Bot mentioned this pull request Jul 2, 2026
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