prometheus-client-c  0.1.1
Prometheus client for the C programming language
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
 A prometheus histogram. More...
 

Functions

prom_histogram_tprom_histogram_new (const char *name, const char *help, prom_histogram_buckets_t *buckets, size_t label_key_count, const char **label_keys)
 Construct a prom_histogram_t*. More...
 
int prom_histogram_destroy (prom_histogram_t *self)
 Destroy a prom_histogram_t*. More...
 
int prom_histogram_observe (prom_histogram_t *self, double value, const char **label_values)
 Observe the prom_histogram_t given the value and labells. More...
 

Detailed Description

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

Typedef Documentation

◆ prom_histogram_t

A prometheus histogram.

References

Function Documentation

◆ prom_histogram_destroy()

int prom_histogram_destroy ( prom_histogram_t self)

Destroy a prom_histogram_t*.

self MUSTS be set to NULL after destruction. Returns a non-zero integer value upon failure.

Returns
Non-zero value upon failure.

◆ prom_histogram_new()

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

Construct a prom_histogram_t*.

Parameters
nameThe name of the metric
helpThe metric description
bucketsThe prom_histogram_buckets_t*. See prom_histogram_buckets.h.
label_key_countis the number of labels associated with the given metric. Pass 0 if the metric 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 constructed prom_histogram_t*

Example

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

// An example without labels
prom_histogram_buckets_t* buckets = prom_histogram_buckets_linear(5.0, 5.0, 10);
prom_histogram_new("foo", "foo is a counter without labels", buckets, 0, NULL);

◆ prom_histogram_observe()

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

Observe the prom_histogram_t given the value and labells.

Parameters
selfThe target prom_histogram_t*
valueThe value to observe
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
Non-zero value upon failure