private async Task AssertExpectedLineProtocolString(MetricsDataValueSource dataValueSource, string expected) { var settings = new MetricsGraphitePlainTextProtocolOptions(); var serializer = new MetricSnapshotSerializer(); var fields = new MetricFields(); fields.DefaultGraphiteMetricFieldNames(); await using var sw = new StringWriter(); await using (var packer = new MetricSnapshotGraphitePlainTextProtocolWriter(sw, settings.MetricPointTextWriter)) { serializer.Serialize(packer, dataValueSource, fields); } sw.ToString().Should().Be(expected); }
public static IMetricsRoot CreateMetrics(string graphiteUri, TimeSpan flushInterval, params string[] pathNodes) { return(AppMetrics.CreateDefaultBuilder() .Report.ToGraphite(g => { g.FlushInterval = flushInterval; g.Graphite.BaseUri = new Uri(graphiteUri); var metricFields = new MetricFields(); metricFields.Histogram.OnlyInclude(HistogramFields.Count, HistogramFields.Max, HistogramFields.Min, HistogramFields.P999, HistogramFields.Sum, HistogramFields.Mean); metricFields.Meter.OnlyInclude(MeterFields.Count, MeterFields.Rate5M, MeterFields.Rate1M, MeterFields.SetItem); metricFields.DefaultGraphiteMetricFieldNames(); g.MetricsOutputFormatter = new MetricsGraphitePlainTextProtocolOutputFormatter( new MetricsGraphitePlainTextProtocolOptions { MetricPointTextWriter = new CustomGraphitePointTextWriter(pathNodes) }, metricFields); }) .Build()); }
public MetricsGraphitePlainTextProtocolOutputFormatter(MetricsGraphitePlainTextProtocolOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); MetricFields = new MetricFields(); MetricFields.DefaultGraphiteMetricFieldNames(); }
public MetricsGraphitePlainTextProtocolOutputFormatter() { _options = new MetricsGraphitePlainTextProtocolOptions(); MetricFields = new MetricFields(); MetricFields.DefaultGraphiteMetricFieldNames(); }