Unit testing the use of metrics

2,385 views
Skip to first unread message

ar...@google.com

unread,
Feb 10, 2015, 5:08:27 PM2/10/15
to prometheus...@googlegroups.com
Hi prometheus-developers,

Is there any way to unit test that my code is setting its metrics the way that I expect? Effectively this would just mean being able to read the value of the metric after running some code that is supposed to set it, I don't see any obvious public way to access the value of a metric in the client_golang library.

Thanks,
Alex

Julius Volz

unread,
Feb 10, 2015, 5:22:31 PM2/10/15
to ar...@google.com, Björn Rabenstein, prometheus-developers
Hey Alex,

Great question! Of course testing metric values should really be supported in some way (especially for jobs that basically only transform metrics from a third-party system into Prometheus metrics), but there were some initial disagreements about how exactly this should work. IIRC these were now mostly resolved. Björn (CCed) can probably best share the current plans for that.

Cheers,
Julius


--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Björn Rabenstein

unread,
Feb 10, 2015, 6:03:17 PM2/10/15
to Julius Volz, ar...@google.com, prometheus-developers
Hi Alex,

The issue you are looking for is
https://github.com/prometheus/client_golang/issues/58 .

We had a lot of discussions around this, and I shall be working on it
quite soon.

The state-of-the-art work around so far is to call the Write() method
of your metrics-to-be-tested and then inspect the protobuf object.

See https://github.com/prometheus/haproxy_exporter/blob/master/haproxy_exporter_test.go#L39
to see how that works in practice. It's not as bad as it sounds, and
it will soon be addressed...

Sorry for that...
Reply all
Reply to author
Forward
0 new messages