prometheus-client-c
0.1.1
Prometheus client for the C programming language
|
A Prometheus collector returns a collection of metrics. More...
Go to the source code of this file.
Typedefs | |
typedef struct prom_collector | prom_collector_t |
A prometheus collector calls collect to prepare metrics and return them to the registry to which it is registered. | |
typedef prom_map_t * | prom_collect_fn(prom_collector_t *self) |
The function responsible for preparing metric data and returning metrics for a given collector. More... | |
Functions | |
prom_collector_t * | prom_collector_new (const char *name) |
Create a collector. More... | |
prom_collector_t * | prom_collector_process_new (const char *limits_path, const char *stat_path) |
Construct a prom_collector_t* which includes the default process metrics. More... | |
int | prom_collector_destroy (prom_collector_t *self) |
Destroy a collector. More... | |
void | prom_collector_free_generic (void *gen) |
Frees a collector passed as a void pointer. More... | |
int | prom_collector_destroy_generic (void *gen) |
Destroys a collector passed as a void pointer. More... | |
int | prom_collector_add_metric (prom_collector_t *self, prom_metric_t *metric) |
Add a metric to a collector. More... | |
int | prom_collector_set_collect_fn (prom_collector_t *self, prom_collect_fn *fn) |
The collect function is responsible for doing any work involving a set of metrics and then returning them for metric exposition. More... | |
A Prometheus collector returns a collection of metrics.
typedef prom_map_t* prom_collect_fn(prom_collector_t *self) |
The function responsible for preparing metric data and returning metrics for a given collector.
If you use the default collector registry, this should not concern you. If you are using a custom collector, you may set this function on your collector to do additional work before returning the contained metrics.
self | The target prom_collector_t* |
int prom_collector_add_metric | ( | prom_collector_t * | self, |
prom_metric_t * | metric | ||
) |
Add a metric to a collector.
self | The target prom_collector_t* |
metric | the prom_metric_t* to add to the prom_collector_t* passed as self. |
int prom_collector_destroy | ( | prom_collector_t * | self | ) |
Destroy a collector.
You MUST set self to NULL after destruction.
self | The target prom_collector_t* |
int prom_collector_destroy_generic | ( | void * | gen | ) |
Destroys a collector passed as a void pointer.
You MUST set self to NULL after destruction.
gen | The target prom_collector_t* represented as a void* |
void prom_collector_free_generic | ( | void * | gen | ) |
Frees a collector passed as a void pointer.
You MUST set self to NULL after destruction.
gen | The target prom_collector_t* represented as a void* |
prom_collector_t* prom_collector_new | ( | const char * | name | ) |
Create a collector.
name | The name of the collector. The name MUST NOT be default or process. |
prom_collector_t* prom_collector_process_new | ( | const char * | limits_path, |
const char * | stat_path | ||
) |
Construct a prom_collector_t* which includes the default process metrics.
limits_path | Pass NULL to discover the path to the /proc/[pid]/limits file associated with process ID assigned by the host environment. Otherwise, pass a string to said path. |
stat_path | Pass NULL to discover the path to the /proc/[pid]/stat file associated with process ID assigned by the host environment. Otherwise, pass a string to said path. |
int prom_collector_set_collect_fn | ( | prom_collector_t * | self, |
prom_collect_fn * | fn | ||
) |
The collect function is responsible for doing any work involving a set of metrics and then returning them for metric exposition.
self | The target prom_collector_t* |
fn | The prom_collect_fn* which will be responsible for handling any metric collection operations before returning the collected metrics for exposition. |