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

Histograms don't support negative values, but should. #3392

Closed
kentquirk opened this issue Jul 25, 2023 · 3 comments
Closed

Histograms don't support negative values, but should. #3392

kentquirk opened this issue Jul 25, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@kentquirk
Copy link
Member

kentquirk commented Jul 25, 2023

I am trying to create an exponential histogram containing negative values.

When I do so, I get [Record amount must be non-negative on Histogram](https://github.com/open-telemetry/opentelemetry-python/blob/8378db984edbc2a0532c5316e82df1ac649ba227/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/instrument.py#L206) -- but as far as I can tell, the spec permits negative values on histograms and explicitly calls out negative value support for Exponential ones (the datatype even includes a collection of buckets called "Negative").

A search of issues and PRs didn't turn up a reason this was excluded. Is there one?

(I've now checked this with .NET and JS, and both of them also exclude negative values. I'm guessing this was added to the spec recently.)

@kentquirk kentquirk added the bug Something isn't working label Jul 25, 2023
@aabmass
Copy link
Member

aabmass commented Jul 27, 2023

This is true for the data model, it can support negative values. However the spec says that Histogram instruments can only record non-negative values:

The value is expected to be non-negative. This API SHOULD be documented in a way to communicate to users that this value is expected to be non-negative. This API SHOULD NOT validate this value, that is left to implementations of the API.

the SDK is an implementation of the API so emits this warning. I couldn't find an issue for this exactly but some related discussion in open-telemetry/opentelemetry-specification#2757. I'd recommend opening a spec issue about this.

@kentquirk
Copy link
Member Author

Thanks for the information. I will follow up on the spec side.

@ocelotl
Copy link
Contributor

ocelotl commented Aug 8, 2023

Closing for the time being, @kentquirk please reopen if necessary after getting input from the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants