Jimdo / prometheus_client_php

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

Counters don't support float values #26

Open tback opened 8 years ago

tback commented 8 years ago

Great work! Noticed one issue though – It seems as if counters don't handle floats yet. The behavior of the redis adapter and the apc adapter differs: Redis completly ignores float values where apc counts their int values and discards the decimal:

Redis

~/s/prometheus_client_php ❯❯❯ docker-compose up -d
~ ❯❯❯ curl 'localhost:8080/examples/some_counter.php?adapter=redis&c=2.7'
OK
~ ❯❯❯ curl 'localhost:8080/examples/some_counter.php?adapter=redis&c=2.7'
OK
~ ❯❯❯ curl 'localhost:8080/examples/metrics.php?adapter=redis'

~ ❯❯❯

APC

~/s/prometheus_client_php ❯❯❯ docker-compose up -d
~/s/prometheus_client_php ❯❯❯ curl 'localhost:8080/examples/some_counter.php?adapter=apc&c=2.7'                                                        OK
~/s/prometheus_client_php ❯❯❯ curl 'localhost:8080/examples/some_counter.php?adapter=apc&c=2.7'                                                        OK
~/s/prometheus_client_php ❯❯❯ curl 'localhost:8080/examples/metrics.php?adapter=apc'                                                                   # HELP test_some_counter it increases
# TYPE test_some_counter counter
test_some_counter{type="blue"} 4

The metric should read 5.4 I guess.

# HELP test_some_counter it increases
# TYPE test_some_counter counter
test_some_counter{type="blue"} 5.4