libprom 1.2.1
C based libraries to expose metrics in Promtheus exposition format
Loading...
Searching...
No Matches
prom_collector.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
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
34typedef struct prom_collector prom_collector_t;
35
47typedef prom_map_t *prom_collect_fn(prom_collector_t *self);
48
57
65
83prom_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
105
111
121
130
146
154
162
163#endif // PROM_COLLECTOR_H
int prom_collector_destroy(prom_collector_t *self)
Destroy the given collector including all attached metrics.
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.
int prom_collector_destroy_generic(void *gen)
Cast the given pointer to prom_collector_t and call prom_collector_destroy() with it.
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
void * prom_collector_data_get(prom_collector_t *self)
Get the pointer to the custom data attached to the given collector.
prom_collector_t * prom_collector_new(const char *name)
Create a collector.
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_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.
void prom_collector_free_generic(void *gen)
Same as prom_collector_destroy_generic(), but drops any return codes.
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.
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 ...
int prom_collector_add_metric(prom_collector_t *self, prom_metric_t *metric)
Add the given metric to the given collector.
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
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