Skip to Main Content
Mastering Elixir
book

Mastering Elixir

by André Albuquerque, Daniel Caixinha
July 2018
Intermediate to advanced content levelIntermediate to advanced
574 pages
14h 7m
English
Packt Publishing
Content preview from Mastering Elixir

Creating custom Prometheus metrics

To implement a custom metric, we will follow the same steps as we did previously: we will first configure our custom metric and then we will create a new Chronometer.defmeasured/2 macro that not only defines a new function, but also emits a histogram metric based on the function name and module.

This time, however, the module that exposes the setup/0 function will be more complex, since it needs to register the metrics and also expose the count/1, observe/2, and observe_duration/2 functions:

$ cat apps/elixir_drip/lib/elixir_drip/prometheus/instrumenter.exdefmodule ElixirDrip.Instrumenter do  use Prometheus  @histograms %{"storage_store" => "Time histogram for the Storage.store/  4 function"} @counters %{"cache_worker_hit" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781788472678Supplemental Content