prometheus-client-c: prom/include/prom_collector_registry.h File Reference

prometheus-client-c 0.1.1 Prometheus client for the C programming language

Typedefs | Functions | Variables
prom_collector_registry.h File Reference

The collector registry registers collectors for metric exposition. More...

`#include "prom_collector.h"`
`#include "prom_metric.h"`
Include dependency graph for prom_collector_registry.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Typedefs
typedef struct prom_collector_registry | prom_collector_registry_t
| A prom_registry_t is responsible for registering metrics and briding them to the string exposition format.

## Functions
int | prom_collector_registry_default_init (void)
| Initializes the default collector registry and enables metric collection on the executing process. More...
prom_collector_registry_t * | prom_collector_registry_new (const char *name)
| Constructs a prom_collector_registry_t*. More...
int | prom_collector_registry_destroy (prom_collector_registry_t *self)
| Destroy a collector registry. More...
int | prom_collector_registry_enable_process_metrics (prom_collector_registry_t *self)
| Enable process metrics on the given collector registry. More...
prom_metric_t * | prom_collector_registry_must_register_metric (prom_metric_t *metric)
| Registers a metric with the default collector on PROM_DEFAULT_COLLECTOR_REGISTRY. More...
int | prom_collector_registry_register_metric (prom_metric_t *metric)
| Registers a metric with the default collector on PROM_DEFAULT_COLLECTOR_REGISTRY. More...
int | prom_collector_registry_register_collector (prom_collector_registry_t *self, prom_collector_t *collector)
| Register a collector with the given registry. More...
const char * | prom_collector_registry_bridge (prom_collector_registry_t *self)
| Returns a string in the default metric exposition format. More...
int | prom_collector_registry_validate_metric_name (prom_collector_registry_t *self, const char *metric_name)
| Validates that the given metric name complies with the specification: More...

## Variables
prom_collector_registry_t * | PROM_COLLECTOR_REGISTRY_DEFAULT
| Initialize the default registry by calling prom_collector_registry_init within your program. More...

## Detailed Description

The collector registry registers collectors for metric exposition.

## Function Documentation

## ◆ prom_collector_registry_bridge()

const char* prom_collector_registry_bridge | ( | prom_collector_registry_t * | self | ) |

Returns a string in the default metric exposition format.

The string MUST be freed to avoid unnecessary heap memory growth.

Reference: https://prometheus.io/docs/instrumenting/exposition_formats/

Parameters

  self | The target prom_collector_registry_t*

Returns
  The string int he default metric exposition format.

## ◆ prom_collector_registry_default_init()

int prom_collector_registry_default_init | ( | void |  | ) |

Initializes the default collector registry and enables metric collection on the executing process.

Returns
  A non-zero integer value upon failure

## ◆ prom_collector_registry_destroy()

int prom_collector_registry_destroy | ( | prom_collector_registry_t * | self | ) |

Destroy a collector registry.

You MUST set self to NULL after destruction.

Parameters

  self | The target prom_collector_registry_t*

Returns
  A non-zero integer value upon failure

## ◆ prom_collector_registry_enable_process_metrics()

int prom_collector_registry_enable_process_metrics | ( | prom_collector_registry_t * | self | ) |

Enable process metrics on the given collector registry.

Parameters

  self | The target prom_collector_registry_t*

Returns
  A non-zero integer value upon failure

## ◆ prom_collector_registry_must_register_metric()

prom_metric_t* prom_collector_registry_must_register_metric | ( | prom_metric_t * | metric | ) |

Registers a metric with the default collector on PROM_DEFAULT_COLLECTOR_REGISTRY.

The metric to be registered MUST NOT already be registered with the given . If so, the program will halt. It returns a prom_metric_t* to simplify metric creation and registration. Furthermore, PROM_DEFAULT_COLLECTOR_REGISTRY must be registered via prom_collector_registry_default_init() prior to calling this function. The metric will be added to the default registry's default collector.

Parameters

  metric | The metric to register on PROM_DEFAULT_COLLECTOR_REGISTRY*

Returns
  The registered prom_metric_t*

## ◆ prom_collector_registry_new()

prom_collector_registry_t* prom_collector_registry_new | ( | const char * | name | ) |

Constructs a prom_collector_registry_t*.

Parameters

  name | The name of the collector registry. It MUST NOT be default.

Returns
  The constructed prom_collector_registry_t*

## ◆ prom_collector_registry_register_collector()

int prom_collector_registry_register_collector | ( | prom_collector_registry_t * | self,
|  | prom_collector_t * | collector
| ) |  |

Register a collector with the given registry.

Returns a non-zero integer value on failure.

Parameters

  self | The target prom_collector_registry_t*
  collector | The prom_collector_t* to register onto the prom_collector_registry_t* as self

Returns
  A non-zero integer value upon failure

## ◆ prom_collector_registry_register_metric()

int prom_collector_registry_register_metric | ( | prom_metric_t * | metric | ) |

Registers a metric with the default collector on PROM_DEFAULT_COLLECTOR_REGISTRY.

Returns an non-zero integer value on failure.

See prom_collector_registry_must_register_metric.

Parameters

  metric | The metric to register on PROM_DEFAULT_COLLECTOR_REGISTRY*

Returns
  A non-zero integer value upon failure

## ◆ prom_collector_registry_validate_metric_name()

int prom_collector_registry_validate_metric_name | ( | prom_collector_registry_t * | self,
|  | const char * | metric_name
| ) |  |

Validates that the given metric name complies with the specification:

Reference: https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels

Returns a non-zero integer value on failure.

Parameters

  self | The target prom_collector_registry_t*
  metric_name | The metric name to validate

Returns
  A non-zero integer value upon failure

## Variable Documentation

## ◆ PROM_COLLECTOR_REGISTRY_DEFAULT

prom_collector_registry_t* PROM_COLLECTOR_REGISTRY_DEFAULT

Initialize the default registry by calling prom_collector_registry_init within your program.

You MUST NOT modify this value.