-
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
Move metric No-Op to metric/noop
#3893
Conversation
0cda726
to
bcb3657
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3893 +/- ##
=======================================
- Coverage 81.8% 81.8% -0.1%
=======================================
Files 169 169
Lines 12855 12859 +4
=======================================
+ Hits 10517 10520 +3
- Misses 2119 2120 +1
Partials 219 219
|
@Aneurysm9: thinking about #3865 last night, I think we don't have to add a private method to all the interfaces, but could still provide this No-Op implementation. That way, an SDK author could choose to:
(This still wouldn't change the Thoughts? |
That works for me as long as the spec stops prohibiting direct construction of no-op implementations. I still think we need giant flashing warning signs telling SDK creators and users that they risk having silently incorrect implementations if they choose to embed no-op implementations. It feels like a bad idea to me, but all the other options are also bad. |
This reverts commit 3c75a44.
…" (open-telemetry#3921)" This reverts commit 795ad97.
* Revert "Revert "Move metric No-Op to metric/noop (#3893)" (#3921)" This reverts commit 795ad97. * Add PR number * Move example_test back to `otel/metric` * Update CHANGELOG.md Co-authored-by: Robert Pająk <[email protected]> * Remove redundant panic tests * Update noop pkg docs --------- Co-authored-by: Robert Pająk <[email protected]>
Fix #3886: the existing way for a user to create a no-op
Meter
without using theMeterProvider
is removed.Move metric No-Op to its own package
The
go.opentelemetry.io/otel/metric
package is intended to primarily be used by instrumentation authors. Having the No-Op implementation in that package, something they will not interact with, only pollutes the API and clutters the documentation for these users.This API pollution and documentation clutter is compounded when exporting No-Op types. It would mean there would be ~20 objects in
go.opentelemetry.io/otel/metric
that all some prefix ofNoop
. Instead of using a prefix to collect common objects, they are moved to their own package.Export No-Op types
Part of #3865 includes providing No-Op implementations for all the API interfaces. These types can then be embedded in implementations that want to default to No-Op behavior instead of panicking.
What about the specification?
All of these requirements mean that the No-Op cannot provide a way for a user to create these types accept via the approved creation types.
I think, given the
noop
package does not provide creation functions for anything other than theMeterProvider
, this approach still satisfies the specification. It true that a user could use the Go language features on their own to create one of these types, but I think the specification would say that the API "must not allow a user to create" these types outside of via the approved creation types.