summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dc57f6e)
raw | patch | inline | side by side (parent: dc57f6e)
author | Florian Forster <octo@collectd.org> | |
Mon, 24 Oct 2016 07:03:32 +0000 (09:03 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 11 Nov 2016 13:42:03 +0000 (14:42 +0100) |
src/write_prometheus.c | patch | blob | history |
diff --git a/src/write_prometheus.c b/src/write_prometheus.c
index 6fb5a8664f3a13be51bc234448020a39bd265e10..43a60fc980d4ef8f0332e239ae09e4737705870a 100644 (file)
--- a/src/write_prometheus.c
+++ b/src/write_prometheus.c
/* metric_family_get looks up the matching metric family, allocating it if
* necessary. */
static Io__Prometheus__Client__MetricFamily *
-metric_family_get(data_set_t const *ds, value_list_t const *vl,
- size_t ds_index) {
+metric_family_get(data_set_t const *ds, value_list_t const *vl, size_t ds_index,
+ _Bool allocate) {
char *name = metric_family_name(ds, vl, ds_index);
if (name == NULL) {
ERROR("write_prometheus plugin: Allocating metric family name failed.");
return fam;
}
+ if (!allocate)
+ return NULL;
+
fam = metric_family_create(name, ds, vl, ds_index);
if (fam == NULL) {
ERROR("write_prometheus plugin: Allocating metric family failed.");
pthread_mutex_lock(&metrics_lock);
for (size_t i = 0; i < ds->ds_num; i++) {
- Io__Prometheus__Client__MetricFamily *fam = metric_family_get(ds, vl, i);
+ Io__Prometheus__Client__MetricFamily *fam =
+ metric_family_get(ds, vl, i, /* allocate = */ 1);
if (fam == NULL)
continue;
pthread_mutex_lock(&metrics_lock);
for (size_t i = 0; i < ds->ds_num; i++) {
- Io__Prometheus__Client__MetricFamily *fam = metric_family_get(ds, vl, i);
+ Io__Prometheus__Client__MetricFamily *fam =
+ metric_family_get(ds, vl, i, /* allocate = */ 0);
if (fam == NULL)
continue;
ERROR("write_prometheus plugin: Deleting a metric in family \"%s\" "
"failed with status %d",
fam->name, status);
+
continue;
}