Skip to content
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

Support for asynchronous Histogram instrument #2713

Open
jmacd opened this issue Aug 5, 2022 · 2 comments
Open

Support for asynchronous Histogram instrument #2713

jmacd opened this issue Aug 5, 2022 · 2 comments
Labels
spec:metrics Related to the specification/metrics directory

Comments

@jmacd
Copy link
Contributor

jmacd commented Aug 5, 2022

What are you trying to achieve?

I was looking to update the https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/runtime Golang runtime metrics package to use the runtime/metrics package introduced in Go-1.16. This package exposes official Go runtime metrics names, gives units and value types and type information needed to translate into OTel's metric data model. The fit is very good, except there are 3 (ordinary) histograms and 1 gauge histogram.

The access method for these metrics use an asynchronous interface. It is impossible for an asynchronous instrument to report a histogram, presently. In an earlier version of the OTel specification, I had proposed that we allow the use of synchronous instruments from asynchronous callbacks--which helped with this problem in the past--but that wouldn't help in the current specification, since each Reader executes callbacks independently, it is now incorrect to allow use of synchronous instruments from asynchronous callbacks.

Adding an asynchronous Histogram instrument would allow (in this case) an efficient transfer of metric data from the Go runtime to the OT. Without such a mechanism, it is really difficult to report this data from a callback. We would need to use a goroutine and synchronous instruments to report these histograms.

What did you expect to see?

The histogram is pre-calculated, meaning the callback receives slices of buckets and counts. Although it would require a lot of new API surface, it would be natural to support an API like Observe(histogram_value) for an asynchronous histogram instrument. It is conceptually challenging to try to report a histogram, otherwise, from an asynchronous callback.

Additional context.

See #607, where the issue of how to report async histogram observations was discussed previously.

@pirgeo
Copy link
Member

pirgeo commented Aug 8, 2022

This would only work for explicit-bucket histograms, right? If you want to transfer it via an exponential histogram, there is no way of converting the information into an exponential histogram without substantial loss of information, or am I missing something?

@reyang
Copy link
Member

reyang commented Aug 18, 2022

This would only work for explicit-bucket histograms, right? If you want to transfer it via an exponential histogram, there is no way of converting the information into an exponential histogram without substantial loss of information, or am I missing something?

I feel this is slightly different from what Instrument is designed for, it seems a better fit for MetricReader (e.g. how OpenTelemetry Java bridges Micrometer with the OpenTelemetry SDK).

@SergeyKanzhelev SergeyKanzhelev removed their assignment Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec:metrics Related to the specification/metrics directory
Projects
None yet
Development

No branches or pull requests

4 participants