Sum metric is integer only
Closed this issue · 2 comments
I had the need to export a duration as sum(), and didn't need distribution(), since I'm only interested in the duration as a total in relation to some other metric I export as counter().
However, when the event is executed, it results in a crash because it runs :ets.update_counter
with a float as the Incr
argument which results in a badarg.
This is the actual error:
13:31:35.068 [error] Handler {TelemetryMetricsPrometheus.Core.EventHandler, #PID<0.945.0>,
[:platform, :parser, :parse_all, :seconds]} has failed and has been detached. Class=:error
Reason=:badarg
Stacktrace=[
{:ets, :update_counter,
[
:prometheus_metrics,
{[:platform, :parser, :parse_all, :seconds],
%{parser_id: "be056e51-250e-486b-b71c-271a381e18de"}},
2.3343e-5,
{{[:platform, :parser, :parse_all, :seconds],
%{parser_id: "be056e51-250e-486b-b71c-271a381e18de"}}, 0}
], [error_info: %{module: :erl_stdlib_errors}]},
{TelemetryMetricsPrometheus.Core.Sum, :handle_event, 4,
[file: 'lib/core/sum.ex', line: 62]},
{:telemetry, :"-execute/3-fun-0-", 4,
[
file: '/Users/tux/projects/zenner/platform-base/platform/deps/telemetry/src/telemetry.erl',
line: 135
]},
{:lists, :foreach_1, 2, [file: 'lists.erl', line: 1442]},
{:telemetry, :span, 3,
[
file: '/Users/tux/projects/zenner/platform-base/platform/deps/telemetry/src/telemetry.erl',
line: 274
]},
{Platform.Parsing.Stage, :"-parse/3-fun-16-", 4,
[file: 'lib/platform/parsing/parse_stage.ex', line: 369]},
{Enum, :"-map/2-fun-0-", 3, [file: 'lib/enum.ex', line: 1662]},
{:maps, :fold_1, 3, [file: 'maps.erl', line: 411]},
{Enum, :map, 2, [file: 'lib/enum.ex', line: 2480]},
{Platform.Parsing.Stage, :handle_events, 3,
[file: 'lib/platform/parsing/parse_stage.ex', line: 57]},
{GenStage, :consumer_dispatch, 6, [file: 'lib/gen_stage.ex', line: 2471]},
{GenStage, :take_pc_events, 3, [file: 'lib/gen_stage.ex', line: 2660]},
{:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 1120]},
{:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 1197]},
{:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}
]
As I said, I've worked around this issue by using distribution()
with buckets like this: [0]
, but this exports 3 extra metrics per label (of which I expect about 1000 in production), which I'm not really interested in.
I think this is an issue with Prometheus metrics, no? This lib does not consume the metrics, only declares them.
You are correct. I will report it there.