public override void report(
            IDictionary <MetricName, Gauge> gauges,
            IDictionary <MetricName, Counter> counters,
            IDictionary <MetricName, Histogram> histograms,
            IDictionary <MetricName, Meter> meters,
            IDictionary <MetricName, Timer> timers)
        {
            long timestamp = DateTime.UtcNow.ToUnixTime();

            try
            {
                if (!graphite.IsConnected)
                {
                    graphite.Connect();
                }

                foreach (KeyValuePair <MetricName, Gauge> entry in gauges)
                {
                    reportGauge(entry.Key, entry.Value, timestamp);
                }

                foreach (KeyValuePair <MetricName, Counter> entry in counters)
                {
                    reportCounter(entry.Key, entry.Value, timestamp);
                }

                foreach (KeyValuePair <MetricName, Histogram> entry in histograms)
                {
                    reportHistogram(entry.Key, entry.Value, timestamp);
                }

                foreach (KeyValuePair <MetricName, Meter> entry in meters)
                {
                    reportMetered(entry.Key, entry.Value, timestamp);
                }

                foreach (KeyValuePair <MetricName, Timer> entry in timers)
                {
                    reportTimer(entry.Key, entry.Value, timestamp);
                }

                graphite.Flush();
            }
            catch (Exception t)
            {
                LOGGER.Warn("Unable to report to Graphite", t);
                Stop();
            }
        }
Exemple #2
0
 /// <inheritdoc />
 public Task <bool> EndAndFlushReportRunAsync(IMetrics metrics) => _graphiteSender.Flush().ContinueWith(t => t.IsCompleted);