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

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

Typedefs | Functions
prom_gauge.h File Reference

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

`#include <stdlib.h>`
`#include "prom_metric.h"`
Include dependency graph for prom_gauge.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_gauge_t
| A prometheus gauge. More...

## Functions
prom_gauge_t * | prom_gauge_new (const char *name, const char *help, size_t label_key_count, const char **label_keys)
| Constructs a prom_gauge_t*. More...
int | prom_gauge_destroy (prom_gauge_t *self)
| Destroys a prom_gauge_t*. More...
int | prom_gauge_inc (prom_gauge_t *self, const char **label_values)
| Increment the prom_gauge_t* by 1. More...
int | prom_gauge_dec (prom_gauge_t *self, const char **label_values)
| Decrement the prom_gauge_t* by 1. More...
int | prom_gauge_add (prom_gauge_t *self, double r_value, const char **label_values)
| Add the value to the prom_gauge_t*. More...
int | prom_gauge_sub (prom_gauge_t *self, double r_value, const char **label_values)
| Subtract the value to the prom_gauge. More...
int | prom_gauge_set (prom_gauge_t *self, double r_value, const char **label_values)
| Set the value for the prom_gauge_t*. More...

## Detailed Description

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

## Typedef Documentation

## ◆ prom_gauge_t

typedef prom_metric_t prom_gauge_t

A prometheus gauge.

References

- See https://prometheus.io/docs/concepts/metric_types/#gauge

## Function Documentation

## ◆ prom_gauge_add()

int prom_gauge_add | ( | prom_gauge_t * | self,
|  | double | r_value,
|  | const char ** | label_values
| ) |  |

Add the value to the prom_gauge_t*.

Parameters

  self | The target prom_gauge_t*
  r_value | The double to add to the prom_gauge_t passed as self.
  label_values | The label values associated with the metric sample being updated. The number of labels must match the value passed to label_key_count in the gauge'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.

Example

    // An example with labels
    prom_gauge_add(foo_gauge 22, (const char**) { "bar", "bang" });

    // An example without labels
    prom_gauge_add(foo_gauge, 22, NULL);

## ◆ prom_gauge_dec()

int prom_gauge_dec | ( | prom_gauge_t * | self,
|  | const char ** | label_values
| ) |  |

Decrement the prom_gauge_t* by 1.

Parameters

  self | The target prom_gauger_t*
  label_values | The label values associated with the metric sample being updated. The number of labels must match the value passed to label_key_count in the gauge'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. Example

      // An example with labels
      prom_gauge_dec(foo_gauge, (const char**) { "bar", "bang" });

      // An example without labels
      prom_gauge_dec(foo_gauge, NULL);

## ◆ prom_gauge_destroy()

int prom_gauge_destroy | ( | prom_gauge_t * | self | ) |

Destroys a prom_gauge_t*.

You must set self to NULL after destruction. A non-zero integer value will be returned on failure.

Parameters

  self | The target prom_gauge_t*

Returns
  A non-zero integer value upon failure

## ◆ prom_gauge_inc()

int prom_gauge_inc | ( | prom_gauge_t * | self,
|  | const char ** | label_values
| ) |  |

Increment the prom_gauge_t* by 1.

Parameters

  self | The target prom_gauger_t*
  label_values | The label values associated with the metric sample being updated. The number of labels must match the value passed to label_key_count in the gauge'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 Example

      // An example with labels
      prom_gauge_inc(foo_gauge, (const char**) { "bar", "bang" });

      // An example without labels
      prom_gauge_inc(foo_gauge, NULL);

## ◆ prom_gauge_new()

prom_gauge_t* prom_gauge_new | ( | const char * | name,
|  | const char * | help,
|  | size_t | label_key_count,
|  | const char ** | label_keys
| ) |  |

Constructs a prom_gauge_t*.

Parameters

  name | The name of the metric
  help | The metric description
  label_key_count | The number of labels associated with the given metric. Pass 0 if the metric does not require labels.
  label_keys | A 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_guage_t*

      // An example with labels
      prom_gauge_new("foo", "foo is a gauge with labels", 2, (const char**) { "one", "two" });

      // An example without labels
      prom_gauge_new("foo", "foo is a gauge without labels", 0, NULL);

## ◆ prom_gauge_set()

int prom_gauge_set | ( | prom_gauge_t * | self,
|  | double | r_value,
|  | const char ** | label_values
| ) |  |

Set the value for the prom_gauge_t*.

Parameters

  self | The target prom_gauge_t*
  r_value | The double to which the prom_gauge_t* passed as self will be set
  label_values | The label values associated with the metric sample being updated. The number of labels must match the value passed to label_key_count in the gauge'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.

Example

    // An example with labels
    prom_gauge_set(foo_gauge 22, (const char**) { "bar", "bang" });

    // An example without labels
    prom_gauge_set(foo_gauge, 22, NULL);

## ◆ prom_gauge_sub()

int prom_gauge_sub | ( | prom_gauge_t * | self,
|  | double | r_value,
|  | const char ** | label_values
| ) |  |

Subtract the value to the prom_gauge.

A non-zero integer value will be returned on failure.

Parameters

  self | The target prom_gauge_t*
  r_value | The double to add to the prom_gauge_t passed as self.
  label_values | The label values associated with the metric sample being updated. The number of labels must match the value passed to label_key_count in the gauge'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.

Example

    // An example with labels
    prom_gauge_sub(foo_gauge 22, (const char**) { "bar", "bang" });

    // An example without labels
    prom_gauge_sub(foo_gauge, 22, NULL);