-
Notifications
You must be signed in to change notification settings - Fork 544
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
fix(host-metrics): widen MeterProvider type restriction in BaseMetrics class #2428
fix(host-metrics): widen MeterProvider type restriction in BaseMetrics class #2428
Conversation
Instead of requiring the `MeterProvider` class implementation as exported by `@opentelemetry/sdk-metrics`, change to simply require the `MeterProvider` interface as exported by `@opentelemtry/api`. This makes `HostMetrics` easier to initialize with the meter provider returned by `metrics.getMeterProvider()`
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2428 +/- ##
==========================================
- Coverage 90.97% 90.71% -0.26%
==========================================
Files 146 156 +10
Lines 7492 7671 +179
Branches 1502 1578 +76
==========================================
+ Hits 6816 6959 +143
- Misses 676 712 +36
|
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.
yep that's better - thanks 👍
Note: waiting for @legendecas approval before merging (component owner) 🙂
(actually @legendecas is out of office for a bit so I'll just merge this - the change seems straight-forward enough) 🙂 |
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.
Thanks!
Does the CLA need to be signed, or is the CLA bot not working? |
@legendecas - I (my company) has already signed the CLA and the commit that I originally pushed shows that the status was successful. I'm not sure why merging |
Instead of requiring the
MeterProvider
class implementation as exported by@opentelemetry/sdk-metrics
, change to simply require theMeterProvider
interface as exported by@opentelemtry/api
. This makesHostMetrics
easier to initialize with the meter provider returned bymetrics.getMeterProvider()
Which problem is this PR solving?
Initializing the
HostMetrics
object with ameterProvider
as returned bymetrics.getMeterProvider()
files a type check:The compile-time error is:
Short description of the changes
Instead of requiring the
MeterProvider
class implementation as exported by@opentelemetry/sdk-metrics
, I've changed theBaseMetrics
abstract class to simply require theMeterProvider
interface as exported by@opentelemtry/api
. This matches the existing behavior where, if nometerProvider
is specified, it usesmetrics.getMeterProvider()
as the default (but emits a warning).