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

Use APC as a storage adapter #25

Closed bracki closed 8 years ago

bracki commented 8 years ago

This PR enables to collect metrics w/o any external dependencies, just by relying on APCu. In order to get it to work with APC (which only allow for atomic operations to work on integers) we use the same technique as in the Golang client.

tback commented 8 years ago

Great work! Noticed one issue though – It seems as if counters don't handle floats yet:

~/s/prometheus_client_php ❯❯❯ docker-compose up
~/s/prometheus_client_php ❯❯❯ curl 'localhost:8080/examples/some_counter.php?adapter=apc&c=2.2'                                                        OK
~/s/prometheus_client_php ❯❯❯ curl 'localhost:8080/examples/some_counter.php?adapter=apc&c=2.2'                                                        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 4.4 I guess.

# HELP test_some_counter it increases
# TYPE test_some_counter counter
test_some_counter{type="blue"} 4.4
bracki commented 8 years ago

@tback Technically yes, the Redis implementation also only supports integers. I'd prefer if you opened another issue.