O'Reilly logo

The DevOps 2.2 Toolkit by Viktor Farcic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Instrumenting services using histograms and summaries

When compared with counters and gauges, histograms are much more complex. That does not mean that they are harder to implement but that the data they provide is less simple when compared with the other metric types we explored. We'll comment on them by studying a sample code and the output it provides.

We'll switch from the vfarcic/docker-flow-swarm-listener (https://github.com/vfarcic/docker-flow-swarm-listener) repository to vfarcic/go-demo (https://github.com/vfarcic/go-demo) since it provides a simple example of a histogram.

Just as with the other types of metrics, histogram also needs to be declared as a variable of the particular type:

var (    histogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required