-
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
Metrics API package structure options #2526
Comments
The 6-package nested layout is prototyped in #2525 |
Thanks for laying this out, this is very helpful.
These assumptions seem right to me. Is open-telemetry/opentelemetry-specification#2270 required to support (3)? As for the layout options, the 6-package nested layout seems like a clear winner to me. It is simple and straightforward and the only "downside" looks to be importing two packages instead of one. I expect that many/most developers have tooling such as |
I don't think we need the My only suggestion for the 6 package layout is to nest the |
Do we want to take some precautions around equivalent interfaces? Right now I don't think this is a problem, but I want to see what others have to think about it. |
This question's been on the back of my mind. Same question for synchronous Counter and UpDownCounter. |
For the flatten pattern:
The "pros" is more than just one import statement, is also one godoc package to check, right now it feels like resolving a maze to find the right godoc for the instrument. Think that users who do not know your "magic" structure, will always start from the top package that contains |
I strongly prefer the 1 package approach. I find it more "idiomatic". The Go standard library also tries to minimize the number of packages for sake of ease of use and discovery. E.g. http package has both server and client functionality. ioutil package has been deprecated and merged into io and os packages. |
Closing as we have produced a revised API based on the discussions found here. We plan to release the new design as an experimental release and continue the evaluation of that design. We can reopen this issue if we find the need to regress back to discussing structure options due to the new design warranting it. |
Problem Statement
The current Metrics API has a number of defects and off-spec features, making it suitable for full-scale replacement. In today's SIG meeting we discussed doing this quickly, to lessen the pain for users. There are a couple of organizations that appear to work, and I'd like feedback from the group.
Proposed Solution
First, the assumptions I'm making: (1) the current sdkapi was created for a pre-generics world, in a post-generics world it doesn't belong in the API, it becomes an ordinary part of the SDK, (2) all batch-recording interfaces will disappear, (3) all
Must*()
forms will disappear, (4) generics will not be used at this time for the API surface (I think we and the users are not ready for this).The result will be the 12 basic instruments organized somehow, plus some way to create asynchronous callbacks and bind them to instruments. I filed a specification issues to carve out support for the proposal here, see open-telemetry/opentelemetry-specification#2280
Assuming favorable outcome, though merging
open-telemetry/opentelemetry-specification#2281
then I would like to outline two potential API structures, described
as "6 packages nested", "1 package nested", and "1 package flattened".
The 6 packages nested layout
In the top-level package, types would be named named
metric.MeterProvider
,metric.Meter
,metric.Option
.In the four specific sub-packages (
syncint64
,syncfloat64
,asyncint64
,asyncfloat64
), there are four interfaces each, one to group the instrument constructors (*.Instruments
) and three concisely-named instruments. For example, there are four instruments named "Counter" (i.e.,syncint64.Counter
,syncfloat64.Counter
,asyncint64.Counter
,asyncfloat64.Counter
).The final
instrument
package is needed to break an import cycle between the others (e.g.,instrument.Option
).Pros: the types all have concise names
Cons: the user has to import 2 packages at least
Synchronous example:
Asynchronous example:
The 1-package nested layout
The structure is similar to the 6-package nested layout but reduced to one large package:
Pros: the user has only one import statement
Cons: the types have longer names; patterns in the API structure are not obvious
Synchronous example:
Asynchronous example:
The 1-package flattened layout
The Meter gains long-name methods, but there are fewer types.
Pros: the user has only one import statement
Cons: the types have longer names; patterns in the API structure are not obvious
Synchronous example:
Asynchronous example:
Summary
While other designs are possible for asynchronous callbacks (and there are open questions there), these three at least summarize the package layout question we have to answer.
The text was updated successfully, but these errors were encountered: