Skip to content
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

feat(api): Add delegating no-op meter provider #4858

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

hectorhdzg
Copy link
Member

@hectorhdzg hectorhdzg commented Jul 9, 2024

Fixes #3622

Short description of the changes

Adding ProxyMeterProvider and ProxyMeter

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit tests

Checklist:

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

@hectorhdzg hectorhdzg requested a review from a team as a code owner July 9, 2024 21:53
@hectorhdzg hectorhdzg changed the title feat(api) Add delegating no-op meter provider feat(api): Add delegating no-op meter provider Jul 11, 2024
Copy link
Contributor

@JacksonWeber JacksonWeber left a comment

Choose a reason for hiding this comment

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

LGTM

@maryliag
Copy link
Contributor

Hey Hector, you marked this as "Breaking change", would you mind providing more info on that?
Also, you still have the template part of "How Has This Been Tested?" on your PR description, you might want to update that 😄

@hectorhdzg
Copy link
Member Author

@maryliag sure thing, this is a breaking change because the behavior of metrics.getMeterProvider would be different now, it will return a ProxyMeterProvider instead of the actual registered meter provider, same as current behavior for tracerProvider

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. 🙂 I think for this to be feasible we also need the instruments to be proxies. 🤔

Comment on lines +51 to +53
createGauge(_name: string, _options?: MetricOptions): Gauge {
return this._getMeter().createGauge(_name, _options);
}
Copy link
Member

Choose a reason for hiding this comment

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

There's a certain difficulty in the case of the metrics API vs the trace/logs APIs - there's another layer that needs to be taken into account, which is the instruments.

In Traces, the (no-op) span is an object which is only kept for the time that the span is active. So one span being no-op is not too problematic. For logs, the record is passed straight to the logger so it's also not a problem there. In metrics however, an instrument is instantiated early and is kept over the lifetime of the app. That means that when a user gets a Meter, they usually also create the Instruments already. A later-updated ProxyMeter would therefore be of very limited help as the instruments would also need to be proxies in order to give a smooth experience.

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.

[api] Implement a delegating no-op MeterProvider
4 participants