public Task WriteAsync(HttpContext context, MetricsDataValueSource metricsData, CancellationToken token = default(CancellationToken))
        {
            var payloadBuilder = new AsciiMetricPayloadBuilder();

            var builder = new MetricDataValueSourceFormatter();

            builder.Build(metricsData, payloadBuilder);

            return(context.Response.WriteAsync(payloadBuilder.PayloadFormatted(), token));
        }
        public Task WriteAsync(HttpContext context, MetricsDataValueSource metricsData, CancellationToken token = default(CancellationToken))
        {
            var payloadBuilder = new BulkPayloadBuilder(
                _index,
                Constants.ElasticsearchDefaults.MetricNameFormatter,
                Constants.ElasticsearchDefaults.MetricTagValueFormatter,
                new MetricValueDataKeys(Constants.ElasticsearchDefaults.CustomHistogramDataKeys, Constants.ElasticsearchDefaults.CustomMeterDataKeys));

            var formatter = new MetricDataValueSourceFormatter();

            formatter.Build(metricsData, payloadBuilder);

            return(context.Response.WriteAsync(payloadBuilder.PayloadFormatted(), token));
        }
        public void can_apply_ascii_metric_formatting_with_custom_name_formatter()
        {
            // Arrange
            var counter = new CounterOptions {
                Context = "test", Name = "counter1"
            };
            var formatter      = new MetricDataValueSourceFormatter();
            var payloadBuilder = new AsciiMetricPayloadBuilder((context, name) => $"{context}---{name}");

            // Act
            _fixture.Metrics.Measure.Counter.Increment(counter);
            formatter.Build(_fixture.Metrics.Snapshot.Get(), payloadBuilder);

            // Assert
            payloadBuilder.PayloadFormatted().Should().Be("# MEASUREMENT: test---counter1\n# TAGS:\n             mtype = counter\n              unit = none\n# FIELDS:\n             value = 1\n--------------------------------------------------------------\n");
        }
Beispiel #4
0
        public void can_apply_custom_ascii_metric_formatting()
        {
            // Arrange
            var counter = new CounterOptions {
                Context = "test", Name = "counter1"
            };
            var formatter      = new MetricDataValueSourceFormatter();
            var payloadBuilder = new CustomAsciiMetricPayloadBuilder();

            // Act
            _fixture.Metrics.Measure.Counter.Increment(counter);
            formatter.Build(_fixture.Metrics.Snapshot.Get(), payloadBuilder);

            // Assert
            payloadBuilder.PayloadFormatted().Should().Be("[test] counter1 counter none value = 1\n");
        }