zostay / raku-Prometheus-Client

A Prometheus Client for Raku
1 stars 2 forks source link

metrics name mangling for counter #2

Open kbucheli opened 4 years ago

kbucheli commented 4 years ago

The Problem

On counters, it adds the _total to the name and creates an additional _created metric. But the TYPE and HELP statements are without the "addons"

According to the Prometheus exposition formats documentation these "addons" are not required for counters. And they do not fit with the actually sent meta data.

Expected Behavior

I would like to have the metrics name as I specify them and I do not need the _created metric.

The same is for units, but there I can opt-in.

Can you think of an opt-out mechanism you would accept?

Steps to Reproduce

use Prometheus::Client :metrics;
use Prometheus::Client::Exposition :render;

my $*PROMETHEUS = Prometheus::Client::CollectorRegistry.new;
my $runs = counter(
    name => 'runs',
    documentation => 'total number of runs',
);
$runs.inc;
print render-metrics($*PROMETHEUS);

produces

# HELP runs total number of runs
# TYPE runs counter
runs_total 1
runs_created 1591350166
kbucheli commented 4 years ago

A suggestion from my side to add that backward compatible is to have a simple flag as argument to the counter, see this commit in my repo on how that can be solved.

Note that it does not fix the wrong meta data for non-simple counters.

zostay commented 4 years ago

Adding a :simple flag would be fine. Another option would be to add a :created flag that defaults to true and then the developer can send :!created to disable it. I think I'd be okay with just making it an opt-in as well and defaulting to false.

kbucheli commented 4 years ago

:created is better, I will prepare an according PR