From: Josef 'Jeff' Sipek Date: Thu, 20 Feb 2020 19:19:29 +0000 (-0500) Subject: stats: Process 'duration' like any other metric value X-Git-Tag: 2.3.11.2~538 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5751df9f21defc1d6f46d8f5a444bf6990d65877;p=thirdparty%2Fdovecot%2Fcore.git stats: Process 'duration' like any other metric value This will allow the soon-to-be-added group-by quantization functions to work on the duration value. --- diff --git a/src/stats/stats-metrics.c b/src/stats/stats-metrics.c index fe0fd4fa72..beb3f3dae2 100644 --- a/src/stats/stats-metrics.c +++ b/src/stats/stats-metrics.c @@ -452,11 +452,9 @@ stats_metric_event_field(struct event *event, const char *fieldname, static void stats_metric_event(struct metric *metric, struct event *event, pool_t pool) { - intmax_t duration; - - event_get_last_duration(event, &duration); - stats_dist_add(metric->duration_stats, duration); - + /* duration is special - we always add it */ + stats_metric_event_field(event, "duration", + metric->duration_stats); for (unsigned int i = 0; i < metric->fields_count; i++) stats_metric_event_field(event, @@ -495,6 +493,13 @@ void stats_metrics_event(struct stats_metrics *metrics, struct event *event, { struct event_filter_match_iter *iter; struct metric *metric; + intmax_t duration; + + /* Note: Adding the field here means that it will get exported + 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); /* process stats */ iter = event_filter_match_iter_init(metrics->stats_filter, event, ctx);