Lines Matching refs:metric
49 int prometheus_format_one_metric(struct prometheus_metric *metric, char *buffer, in prometheus_format_one_metric() argument
55 if (metric->description[0] != '\0') { in prometheus_format_one_metric()
57 "# HELP %s %s\n", metric->name, in prometheus_format_one_metric()
58 metric->description); in prometheus_format_one_metric()
66 switch (metric->type) { in prometheus_format_one_metric()
69 "# TYPE %s counter\n", metric->name); in prometheus_format_one_metric()
79 "# TYPE %s gauge\n", metric->name); in prometheus_format_one_metric()
89 "# TYPE %s histogram\n", metric->name); in prometheus_format_one_metric()
99 "# TYPE %s summary\n", metric->name); in prometheus_format_one_metric()
109 "# TYPE %s untyped\n", metric->name); in prometheus_format_one_metric()
119 switch (metric->type) { in prometheus_format_one_metric()
122 CONTAINER_OF(metric, struct prometheus_counter, base); in prometheus_format_one_metric()
126 for (int i = 0; i < metric->num_labels; ++i) { in prometheus_format_one_metric()
129 "%s{%s=\"%s\"} %llu\n", metric->name, metric->labels[i].key, in prometheus_format_one_metric()
130 metric->labels[i].value, counter->value); in prometheus_format_one_metric()
142 CONTAINER_OF(metric, struct prometheus_gauge, base); in prometheus_format_one_metric()
146 for (int i = 0; i < metric->num_labels; ++i) { in prometheus_format_one_metric()
149 "%s{%s=\"%s\"} %f\n", metric->name, metric->labels[i].key, in prometheus_format_one_metric()
150 metric->labels[i].value, gauge->value); in prometheus_format_one_metric()
162 CONTAINER_OF(metric, struct prometheus_histogram, base); in prometheus_format_one_metric()
169 "%s_bucket{le=\"%f\"} %lu\n", metric->name, in prometheus_format_one_metric()
179 "%s_sum %f\n", metric->name, histogram->sum); in prometheus_format_one_metric()
186 "%s_count %lu\n", metric->name, in prometheus_format_one_metric()
198 CONTAINER_OF(metric, struct prometheus_summary, base); in prometheus_format_one_metric()
205 "%s{%s=\"%f\"} %f\n", metric->name, "quantile", in prometheus_format_one_metric()
215 "%s_sum %f\n", metric->name, summary->sum); in prometheus_format_one_metric()
222 "%s_count %lu\n", metric->name, in prometheus_format_one_metric()
234 LOG_ERR("Unsupported metric type %d", metric->type); in prometheus_format_one_metric()
246 struct prometheus_metric *metric; in prometheus_format_exposition() local
258 SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&collector->metrics, metric, tmp, node) { in prometheus_format_exposition()
262 ret = collector->user_cb(collector, metric, collector->user_data); in prometheus_format_exposition()
274 ret = prometheus_format_one_metric(metric, buffer, buffer_size, &written); in prometheus_format_exposition()