From fcdaab6b20d0fe106321a88b72ce36be2bb56dfb Mon Sep 17 00:00:00 2001 From: Siavash Tavakoli Date: Thu, 18 Feb 2021 21:39:09 +0000 Subject: [PATCH] stats: refactor duration field name into a macro --- src/stats/stats-metrics.c | 4 ++-- src/stats/stats-metrics.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stats/stats-metrics.c b/src/stats/stats-metrics.c index ea5083deb0..3dc8b7717d 100644 --- a/src/stats/stats-metrics.c +++ b/src/stats/stats-metrics.c @@ -504,7 +504,7 @@ static void stats_metric_event(struct metric *metric, struct event *event, pool_t pool) { /* duration is special - we always add it */ - stats_metric_event_field(event, "duration", + stats_metric_event_field(event, STATS_EVENT_FIELD_NAME_DURATION, metric->duration_stats); for (unsigned int i = 0; i < metric->fields_count; i++) @@ -550,7 +550,7 @@ void stats_metrics_event(struct stats_metrics *metrics, struct event *event, below. This is necessary to allow group-by functions to quantize based on the event duration. */ event_get_last_duration(event, &duration); - event_add_int(event, "duration", duration); + event_add_int(event, STATS_EVENT_FIELD_NAME_DURATION, duration); /* process stats */ iter = event_filter_match_iter_init(metrics->stats_filter, event, ctx); diff --git a/src/stats/stats-metrics.h b/src/stats/stats-metrics.h index 1328da1133..587b4b4f7e 100644 --- a/src/stats/stats-metrics.h +++ b/src/stats/stats-metrics.h @@ -4,6 +4,8 @@ #include "stats-settings.h" #include "sha1.h" +#define STATS_EVENT_FIELD_NAME_DURATION "duration" + struct metric; struct exporter { -- 2.47.3