-
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
[proposal] Move instrument creation configuration to otel/metric
#3995
Comments
In my opinion, it would make sense if we also move the instrument types. For example a type like If we do not do that the API users would probably still need to import the instrument package in order to pass the instrument objects between functions in the instrumentation libraries or application code (for "domain" metrics). Example: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/e0d1de8735ab70a480002a1972e8ffa15e7f46f9/instrumentation/net/http/otelhttp/handler.go#L53-L54. As far as I see, if we move these types it would simply mean that we would move the whole |
It would mean that two "levels" of option would leave in a single package. Options for creating a meter and options for creating instruments. I am a little afraid of a possible name collision of those two options (like usage, err := meter.Int64ObservableUpDownCounter(
"db.client.connections.usage",
metric.Unit("{connection}"),
metric.Description("The number of connections that are currently in state described by the state attribute"),
) Similar pattern is adopted in https://pkg.go.dev/google.golang.org/grpc |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I'm hesitant to deviate from our established options pattern here. I don't see how we can normatively state how option should be named if we sometimes allow this kind of exception. There isn't a reason that I can see that will explain what we have done to this point and still allow this kind of deviation. |
With the reduction of measurement options added in #3971 reduced to 3 (9 total added declarations), this move is less compelling. There still seems like a motivation to want the types and functions to be in the same package they are used, but there is less bloat to I think if we wanted to move the instrument configuration we will likely also want to move the whole |
I've read that meters have instruments, but it's not clear to me yet whether API callers care about the distinction. Forcing mention of the separate package into calling code is a distraction. The separation may be useful to SDK authors. If it is, why is that so? |
It doesn't make too much of a difference for an SDK. They need to import two package as well in the implementation. I'm pretty sure the original reason for this was just to reduce the docs surface area. Which I'm reconsidering as a negative as it requires looking elsewhere for the full docs. |
In order to justify the separation of packages, I'd look for things that |
As far as I know, neither of these conditions exist. The flattening is prototyped in #4018 if you want to take a look. |
## This PR Upgrade OTEL dependencies. PR fix API deprecations & upgrade to latest recommendations. OTEL Go release notes - https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.15.0 Note - Refer OTEL Proposal [1] & PR [2] for breaking changes [1] - open-telemetry/opentelemetry-go#3995 [2] - open-telemetry/opentelemetry-go#4018 Signed-off-by: Kavindu Dodanduwa <[email protected]>
Background
Currently the following declarations are made in the
go.opentelemetry.io/otel/metric/instrument
:Int64CounterOption
Int64UpDownCounterOption
Int64HistogramOption
Int64ObservableCounterOption
Int64ObservableUpDownCounterOption
Int64ObservableGaugeOption
Float64CounterOption
Float64UpDownCounterOption
Float64HistogramOption
Float64ObservableCounterOption
Float64ObservableUpDownCounterOption
Float64ObservableGaugeOption
Int64CounterConfig
Int64UpDownCounterConfig
Int64HistogramConfig
Int64ObservableCounterConfig
Int64ObservableUpDownCounterConfig
Int64ObservableGaugeConfig
Float64CounterConfig
Float64UpDownCounterConfig
Float64HistogramConfig
Float64ObservableCounterConfig
Float64ObservableUpDownCounterConfig
Float64ObservableGaugeConfig
NewInt64CounterConfig
NewInt64UpDownCounterConfig
NewInt64HistogramConfig
NewInt64ObservableCounterConfig
NewInt64ObservableUpDownCounterConfig
NewInt64ObservableGaugeConfig
NewFloat64CounterConfig
NewFloat64UpDownCounterConfig
NewFloat64HistogramConfig
NewFloat64ObservableCounterConfig
NewFloat64ObservableUpDownCounterConfig
NewFloat64ObservableGaugeConfig
WithUnit
WithDescription
WithInt64Callback
WithFloat64Callback
While each option and config are related to an instrument defined in
go.opentelemetry.io/otel/metric/instrument
, they are never used there. The options are all used when calling a method from aMeter
in thego.opentelemetry.io/otel/metric
package:opentelemetry-go/metric/meter.go
Lines 54 to 106 in eb2b89f
Issue
Having these configuration options exist in a package that they are not used by seems incorrect.
go.opentelemetry.io/otel/metric
to create a meter and an instrument, but they will also have to importgo.opentelemetry.io/otel/metric/instrument
to configure the instrument they are creating.go.opentelemetry.io/otel/metric
a user may not need to importgo.opentelemetry.io/otel/metric/instrument
go.opentelemetry.io/otel/metric
a user would be able to read the documentation of that package alone and understand how to create and configure an instrumentgo.opentelemetry.io/otel/metric/instrument
packagego.opentelemetry.io/otel/metric/instrument
that are not used bygo.opentelemetry.io/otel/metric/instrument
distracts from the things that the package is dedicated to providing (instrument types).Proposal
Move all of the listed configuration declarations to
go.opentelemetry.io/otel/metric
.The text was updated successfully, but these errors were encountered: