Skip to content

Improve performance: Don't request current context when creating a measurement#4253

Closed
fcollonval wants to merge 1 commit intoopen-telemetry:mainfrom
fcollonval:fix/4243-exemplar-performance
Closed

Improve performance: Don't request current context when creating a measurement#4253
fcollonval wants to merge 1 commit intoopen-telemetry:mainfrom
fcollonval:fix/4243-exemplar-performance

Conversation

@fcollonval
Copy link
Copy Markdown
Contributor

Description

Fixes #4243

Make Measurement.context optional and stop requesting the current context when creating a measurement

Type of change

Improve code performance following degradation with #4094

How Has This Been Tested?

I run locally the benchmarks to check the improvement.
I also tried the metrics benchmark with exemplar deactivate (aka setting exemplar filter to always off); it also show slight performance boost

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

@fcollonval
Copy link
Copy Markdown
Contributor Author

@emdneto here is my attempt to restore code performance to its level prior to the introduction of the exemplar in #4094

As the project has been released with the new API for measurement, aka it has a context attribute, instead of dropping it as discussed, I made it optional and drop all call to get_current().

Do you think it would be better to drop the context attribute altogether?

Would it make sense to add benchmark with exemplar deactivated?

If so what is the best way of doing so?

I guess using pytest parametrize to change the type of exemplar filter is not a great idea as it will change the name of the benchmark tests and prevent comparison with the old results.

@fcollonval fcollonval changed the title Don't request current context when creating a measurement Improve performance: Don't request current context when creating a measurement Nov 9, 2024
@github-actions
Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions bot added the Stale label Mar 12, 2026
@github-actions
Copy link
Copy Markdown

This PR has been closed due to inactivity. Please reopen if you would like to continue working on it.

@github-actions github-actions bot closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sdk/metrics: performance impact of exemplars support even when configured as always_off

1 participant