-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add Instrument.IsEnabled per specs #5768
Add Instrument.IsEnabled per specs #5768
Conversation
|
c91ecd8
to
da6a123
Compare
Looks like the status is still Development: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#enabled. We will need to wait for this to go stable before we can add it to the stable API. |
8f05c4b
to
3b558f0
Compare
I am extremely confused by this, because for logs it is also development, see opentelemetry-go/log/logger.go Line 52 in 9339b21
|
@dashpole will work on that stability, but before that can you tell me if you prefer |
Signed-off-by: Bogdan Drutu <[email protected]>
3b558f0
to
b6ed797
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5768 +/- ##
=======================================
- Coverage 84.5% 84.5% -0.1%
=======================================
Files 272 272
Lines 22759 22819 +60
=======================================
+ Hits 19253 19283 +30
- Misses 3166 3194 +28
- Partials 340 342 +2 |
I have a slight preference for IsEnabled(), but that would require changing the logs api as well. |
Stabilizing of
In such case, we may also want to update the specification as well. In Trace API we have methods like On the other hand, the Go standard library has e.g. Personally, as rule of thumb, I find adding |
The choice between |
Because of this I would suggest "IsEnabled". |
// IsEnabled returns true if this instrument is enabled. | ||
// | ||
// This helps users avoid performing computationally expensive operations when | ||
// recording measurements. The returned value cannot be cached since it |
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.
// recording measurements. The returned value cannot be cached since it | |
// recording measurements. The returned value should not be cached since it |
felt this is more apt, but feel free to ignore this comment, as I don't have full context on Otel Go!
To move this PR along, would it be enough to add an optional experimental This would allow the Collector to use this functionality and validate that the interface works for our use-case |
I don't think we can make any changes to the public API or SDK interfaces while it is experimental, so some ideas are:
|
@dashpole looking at this current PR, I'm not sure how the functionality would be implemented in a wrapper in the collector as the check depends on internals for all instruments. The other option sounds like the correct one, as any future functionality will need to be exposed in a similar way. |
I would prefer not maintaining a duplicate package to support an experimental PoC of a feature. Why can't the fork this already exists in be used if a user wants to try this out? |
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.
Blocking as this is proposing an experimental API to a stable package.
Changing to draft as there is no work here. |
Opening this to get feedback on whether or not I'm headed in the right direction based on the details listed in open-telemetry#6002. This is a replacement for open-telemetry#5768 Fixes open-telemetry#6002 There are still some tests I would add, but overall I'm mostly looking to reviewers to let me know if this is the correct approach (defining an interface in `x` and using that interface in the SDK) Signed-off-by: Alex Boten <[email protected]>
Closing per #6016 |
This PR is based on open-telemetry/opentelemetry-specification#4063
In this PR, the async instruments are ignored because open-telemetry/opentelemetry-specification#4200, if that is not what we want I will add support for async instruments in a later PR.