-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return consistent Meter
for a given MeterProvider
#1351
Conversation
Codecov ReportAttention:
📢 Thoughts on this report? Let us know! |
# Conflicts: # opentelemetry-sdk/src/metrics/meter_provider.rs
|
||
Meter::new(inst_provider) | ||
if let Ok(mut meters) = self.meters.lock() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the fact that obtaining meter
is not free, we should mention in the documentation that, meter (and instruments) should be obtained once and cached by user to avoid perf hit. Not blocking this PR, but wanted to call it out here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do some benchmarking in a follow up and have better guidelines on metric perf in general. The use case for accessing a meter is different than a tracer or logger as instruments are more likely to be a fixed set. And even in those cases repeatedly creating/accessing instruments could be the place that needs perf considerations.
# Conflicts: # opentelemetry-sdk/CHANGELOG.md
Changes
Adds a meter cache to return consistent
Meter
instances for the same scope. Meters have their own instrument caches so this avoids double instrument registration.Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes