libprom 1.2.1
C based libraries to expose metrics in Promtheus exposition format
Loading...
Searching...
No Matches
prom_collector_registry.h
Go to the documentation of this file.
1/*
2Copyright 2019-2020 DigitalOcean Inc.
3Copyright 2021 Jens Elkner <jel+libprom@cs.uni-magdeburg.de>
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16*/
17
23#ifndef PROM_REGISTRY_H
24#define PROM_REGISTRY_H
25
26#include <stdbool.h>
27#include "prom_collector.h"
28#include "prom_metric.h"
29
32#define METRIC_LABEL_SCRAPE "libprom"
35#define METRIC_NAME_SCRAPE "scrape_duration_seconds"
39#define COLLECTOR_NAME_DEFAULT "default"
42#define COLLECTOR_NAME_PROCESS "process"
45#define REGISTRY_NAME_DEFAULT "default"
46
74
78typedef unsigned int PROM_INIT_FLAGS;
79
83typedef struct pcr pcr_t;
84
91#define PROM_COLLECTOR_REGISTRY_DEFAULT PROM_COLLECTOR_REGISTRY
92
101
112int pcr_init(PROM_INIT_FLAGS features, const char *mprefix);
113
120pcr_t *pcr_new(const char *name);
121
135
142
153
168
179
188
197prom_collector_t *pcr_get(pcr_t *self, const char *name);
198
209char *pcr_bridge(pcr_t *self);
210
225int pcr_validate_metric_name(pcr_t *self, const char *metric_name);
226
237int pcr_check_name(const char *name, bool is_label);
238
239#endif // PROM_H
A prom_collector is used to collect metrics.
struct prom_collector prom_collector_t
A prom collector calls collect to prepare metrics and return them to the registry to which it is regi...
Definition prom_collector.h:34
prom_init_flag
flags for the setup of a prom collector registry.
Definition prom_collector_registry.h:51
@ PROM_SCRAPETIME_ALL
Implies PROM_SCRAPETIME, but measures and dumps the dump time of every single collector as well.
Definition prom_collector_registry.h:67
@ PROM_SCRAPETIME
Automatically create and use a metric to monitor the time needed to dump all the metrics of all regis...
Definition prom_collector_registry.h:63
@ PROM_COMPACT
Omit any "# HELP" and "# TYPE" lines in metric exports.
Definition prom_collector_registry.h:72
@ PROM_PROCESS
Automatically setup and attach a process collector, which collects stats of this process on pcr_bridg...
Definition prom_collector_registry.h:57
@ PROM_NONE
placeholder for 0 - implies nothing
Definition prom_collector_registry.h:53
int pcr_init(PROM_INIT_FLAGS features, const char *mprefix)
Initializes the default collector registry PROM_COLLECTOR_REGISTRY named REGISTRY_NAME_DEFAULT.
pcr_t * PROM_COLLECTOR_REGISTRY
Initialize the default registry by calling pcr_init() within your app.
int pcr_enable_scrape_metrics(pcr_t *self)
Create a scrape duration gauge metric and attach it to the given prom collector registry.
int pcr_register_collector(pcr_t *self, prom_collector_t *collector)
Register a collector with the given registry.
int pcr_check_name(const char *name, bool is_label)
Check whether the given label | metric name complies with the specification:
int pcr_register_metric(prom_metric_t *metric)
Registers a metric with the default collector on PROM_COLLECTOR_REGISTRY.
int pcr_validate_metric_name(pcr_t *self, const char *metric_name)
Validates that the given metric name complies with the specification:
pcr_t * pcr_new(const char *name)
Constructs a registry named default which contains one empty prom collector named default ,...
int pcr_destroy(pcr_t *self)
Destroy the given collector registry.
int pcr_default_init(void)
Initializes the default collector registry.
unsigned int PROM_INIT_FLAGS
collection of prom collector registry features.
Definition prom_collector_registry.h:78
int pcr_enable_process_metrics(pcr_t *self)
Enable process metrics on the given collector registry.
char * pcr_bridge(pcr_t *self)
Export all relevant metrics registered with the given registry in the default metric exposition forma...
prom_metric_t * pcr_must_register_metric(prom_metric_t *metric)
Registers a metric with the default collector on PROM_COLLECTOR_REGISTRY.
struct pcr pcr_t
A prom_registry_t is responsible for registering metrics and briding them to the string exposition fo...
Definition prom_collector_registry.h:83
prom_collector_t * pcr_get(pcr_t *self, const char *name)
Get a reference to the prom collector with the given name from the given prom collector registry.
Functions for retrieving metric samples from metrics given an ordered set of labels.
struct prom_metric prom_metric_t
A prometheus metric.
Definition prom_metric.h:43