libprom  1.2.0
C based libraries to expose metrics in Promtheus exposition format
Typedefs | Functions
prom_histogram.h File Reference

https://prometheus.io/docs/concepts/metric_types/#histogram More...

#include <stdlib.h>
#include "prom_histogram_buckets.h"
#include "prom_metric.h"
Include dependency graph for prom_histogram.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef prom_metric_t prom_histogram_t
 Prometheus metric: histogram. More...
 

Functions

prom_histogram_tprom_histogram_new (const char *name, const char *help, phb_t *buckets, size_t label_key_count, const char **label_keys)
 Construct a new metric of type histogram (or short: histogram) More...
 
int prom_histogram_destroy (prom_histogram_t *self)
 Destroy the given histogram. More...
 
int prom_histogram_observe (prom_histogram_t *self, double value, const char **label_values)
 Observe the given value of the given histogram with the given labels. More...
 

Detailed Description

https://prometheus.io/docs/concepts/metric_types/#histogram

Typedef Documentation

◆ prom_histogram_t

Prometheus metric: histogram.

References

Function Documentation

◆ prom_histogram_destroy()

int prom_histogram_destroy ( prom_histogram_t self)

Destroy the given histogram.

Returns
Non-zero value upon failure, 0 otherwise.
Note
No matter what gets returned, you should never use any metric passed to this function but set it to NULL .

◆ prom_histogram_new()

prom_histogram_t* prom_histogram_new ( const char *  name,
const char *  help,
phb_t buckets,
size_t  label_key_count,
const char **  label_keys 
)

Construct a new metric of type histogram (or short: histogram)

Parameters
nameName of the histogram.
helpSort histogram description.
bucketsBuckets to assign. See prom_histogram_buckets.h .
label_key_countThe number of labels associated with the given histogram. Pass 0 if the histogram does not require labels.
label_keysA collection of label keys. The number of keys MUST match the value passed as label_key_count. If no labels are required, pass NULL. Otherwise, it may be convenient to pass this value as a literal.
Returns
The new prom histogram on success, NULL otherwise.

Example

// An example with labels phb_t* buckets = phb_linear(5.0, 5.0, 10); prom_histogram_new("foo", "foo is a histogram with labels", buckets, 2, (const char**) { "one", "two" });

// An example without labels phb_t* buckets = phb_linear(5.0, 5.0, 10); prom_histogram_new("foo", "foo is a histogram without labels", buckets, 0, NULL);

◆ prom_histogram_observe()

int prom_histogram_observe ( prom_histogram_t self,
double  value,
const char **  label_values 
)

Observe the given value of the given histogram with the given labels.

Parameters
selfHistogram to observe.
valueValue to observe.
label_valuesThe label values associated with the histogram sample being updated. The number of labels must match the value passed as label_key_count in the histogram's constructor. If no label values are necessary, pass NULL. Otherwise, it may be convenient to pass this value as a literal.
Returns
A non-zero integer value upon failure, 0 otherwise.