libprom  1.2.0
C based libraries to expose metrics in Promtheus exposition format
prom_collector.h
Go to the documentation of this file.
1 /*
2 Copyright 2019-2020 DigitalOcean Inc.
3 Copyright 2021 Jens Elkner <jel+libprom@cs.uni-magdeburg.de>
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */
17 
18 #ifndef PROM_COLLECTOR_H
19 #define PROM_COLLECTOR_H
20 
21 #include <sys/types.h>
22 #include "prom_map.h"
23 #include "prom_metric.h"
24 
34 typedef struct prom_collector prom_collector_t;
35 
47 typedef prom_map_t *prom_collect_fn(prom_collector_t *self);
48 
57 
64 prom_collector_t *prom_collector_new(const char *name);
65 
83 prom_collector_t *ppc_new(const char *limits_path, const char *stat_path, pid_t pid, const char **label_keys, const char **label_vals);
84 
96 
97 
104 int prom_collector_destroy_generic(void *gen);
105 
110 void prom_collector_free_generic(void *gen);
111 
121 
130 
146 
154 
162 
163 #endif // PROM_COLLECTOR_H
prom_collector_add_metric
int prom_collector_add_metric(prom_collector_t *self, prom_metric_t *metric)
Add the given metric to the given collector.
ppc_new
prom_collector_t * ppc_new(const char *limits_path, const char *stat_path, pid_t pid, const char **label_keys, const char **label_vals)
Create a prom collector which includes the default process metrics.
prom_metric.h
Functions for retrieving metric samples from metrics given an ordered set of labels.
prom_metric_t
struct prom_metric prom_metric_t
A prometheus metric.
Definition: prom_metric.h:43
prom_collector_new
prom_collector_t * prom_collector_new(const char *name)
Create a collector.
prom_collector_destroy_generic
int prom_collector_destroy_generic(void *gen)
Cast the given pointer to prom_collector_t and call prom_collector_destroy() with it.
prom_collector_free_data_fn
void prom_collector_free_data_fn(prom_collector_t *self)
The function to use to cleanup and free custom data attached via prom_collector_data_set().
Definition: prom_collector.h:56
prom_collector_data_set
void * prom_collector_data_set(prom_collector_t *self, void *data, prom_collector_free_data_fn *fn)
Attach custom data to the given collector as well as the callback to use to clean it up.
prom_collector_free_generic
void prom_collector_free_generic(void *gen)
Same as prom_collector_destroy_generic(), but drops any return codes.
prom_collector_metrics_get
prom_map_t * prom_collector_metrics_get(prom_collector_t *self)
Get a map of all metrics of the given collector keyed by their names.
prom_collector_data_get
void * prom_collector_data_get(prom_collector_t *self)
Get the pointer to the custom data attached to the given collector.
prom_collect_fn
prom_map_t * prom_collect_fn(prom_collector_t *self)
The function used to prepare and return all relevant metrics of the given collector ready for Prometh...
Definition: prom_collector.h:47
prom_collector_set_collect_fn
int prom_collector_set_collect_fn(prom_collector_t *self, prom_collect_fn *fn)
Set the function, which prepares (if needed) and returns all relevant metrics of the given collector ...
prom_collector_destroy
int prom_collector_destroy(prom_collector_t *self)
Destroy the given collector including all attached metrics.
prom_collector_t
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