Skip to content

Commit

Permalink
decode_prometheus_remote_write: Detect histogram type of payloads if …
Browse files Browse the repository at this point in the history
…included

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 authored and edsiper committed Apr 26, 2024
1 parent e91c0ef commit f4cf560
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cmt_decode_prometheus_remote_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ static int decode_metrics_entry(struct cmt *cmt,
void *instance;
int result;
int ts_count = 0;
int hist_count = 0;
int meta_count = 0;
Prometheus__MetricMetadata *metadata = NULL;
Prometheus__MetricMetadata__MetricType type;
Expand All @@ -526,13 +527,18 @@ static int decode_metrics_entry(struct cmt *cmt,
for (i = 0; i < ts_count; i++) {
ts = write->timeseries[i];
meta_count = write->n_metadata;
hist_count = ts->n_histograms;
if (meta_count > 0) {
metadata = write->metadata[i];
}
if (metadata == NULL) {
type = PROMETHEUS__METRIC_METADATA__METRIC_TYPE__GAUGE;
metric_description = "-";
}
else if (hist_count > 0) {
type = PROMETHEUS__METRIC_METADATA__METRIC_TYPE__HISTOGRAM;
metric_description = "-";
}
else {
type = write->metadata[i]->type;
metric_description = write->metadata[i]->help;
Expand Down

0 comments on commit f4cf560

Please sign in to comment.