open-telemetry / opentelemetry-erlang

OpenTelemetry Erlang SDK
https://opentelemetry.io
Apache License 2.0
331 stars 105 forks source link

Views can not control boundaries in histograms #629

Open RoadRunnr opened 1 year ago

RoadRunnr commented 1 year ago

According to https://opentelemetry.io/docs/specs/otel/metrics/sdk/#aggregation is should be possible to add a View to an Instrument and define how that View translates that Instrument to an Histogram. In particular, the defined Boundaries in the View should be used instead of the default histogram boundaries.

That does not seem to work at all.

If I understand the code correctly, then instrument created with kind histogram will not honor the view settings at all.

This has also been discussed to other languages, e.g.:

If I do this:

otel_meter_server:add_view(#{instrument_kind => ?KIND_HISTOGRAM},
                           #{aggregation_options =>
                                 #{boundaries => [0.0, 1.1, 2.2, 4.4, 8.8]}}),
?create_histogram('meter1', #{description => <<"Meter 1">>, unit => us}),

then the the created histogram should have the boundaries defined by the view, but instead it will have the ?DEFAULT_BOUNDARIES.

albertored commented 1 year ago

HI @RoadRunnr, I think I have (involuntarily) fixed this on this PR: https://github.com/open-telemetry/opentelemetry-erlang/pull/628, could you try with that branch?

albertored commented 1 year ago

@RoadRunnr just added a specific test on that PR (https://github.com/open-telemetry/opentelemetry-erlang/pull/628/commits/34e827175723e693dfdec2788d367fe0ba070baa) and I confirm it will fix your bug

tsloughter commented 1 year ago

great! will get that merged in

RoadRunnr commented 1 year ago

@albertored confirmed, works as expected with that change :+1: