PromPHP / prometheus_client_php

Prometheus instrumentation library for PHP applications
https://prometheus.io/docs/concepts/metric_types/
Apache License 2.0
424 stars 93 forks source link

Label values proposal #58

Open Bogdaan opened 3 years ago

Bogdaan commented 3 years ago

Agenda

As a developer, I want to send correct label values to prometheus.

Example:

metric name : engine_cpu
label: instance = n1
label: size = "10 inches"
increment: 1

How can I send this metric:

\Prometheus\CollectorRegistry::getDefault()
    ->getOrRegisterCounter('factory', 'engine_cpu', 'factory engine state', ['instance' => 'n1', 'size' => '10 inches']);
    ->inc();

But, I got an error:

Invalid label name: '10 inches'

Because assertValidLabel function validates label values, not label names https://github.com/PromPHP/prometheus_client_php/blob/bca39eb7cbdbeeed9896aa077c18ab55372eee55/src/Prometheus/Collector.php#L114

Proposal