public void Serialize() { using (var stream = new MemoryStream(_outputBuffer)) { AsciiFormatter.Format(stream, _data); } }
public static string ProcessScrapeRequest( IEnumerable <Advanced.DataContracts.MetricFamily> collected, string contentType) { if (contentType == ProtoContentType) { throw new NotImplementedException(); } else { return(AsciiFormatter.Format(collected)); } }
public static void ProcessScrapeRequest( IEnumerable <Advanced.DataContracts.MetricFamily> collected, string contentType, Stream outputStream) { if (contentType == ProtoContentType) { ProtoFormatter.Format(outputStream, collected); } else { AsciiFormatter.Format(outputStream, collected); } }
public async Task WriteAsync( Stream output, MetricsDataValueSource metricsData, CancellationToken cancellationToken = default(CancellationToken)) { if (output == null) { throw new ArgumentNullException(nameof(output)); } var prometheusMetricsSnapshot = metricsData.GetPrometheusMetricsSnapshot(_options.MetricNameFormatter); await AsciiFormatter.Write(output, prometheusMetricsSnapshot, _options.NewLineFormat); }
public void family_should_be_formatted_to_one_line(string labelValue) { using (var ms = new MemoryStream()) { var metricFamily = new MetricFamily { name = "family1", help = "help", type = MetricType.COUNTER, }; var metricCounter = new Advanced.DataContracts.Counter { value = 100 }; metricFamily.metric.Add(new Metric { counter = metricCounter, label = new List <LabelPair> { new LabelPair { name = "label1", value = labelValue } } }); AsciiFormatter.Format(ms, new[] { metricFamily }); using (var sr = new StringReader(Encoding.UTF8.GetString(ms.ToArray()))) { var linesCount = 0; var line = ""; while ((line = sr.ReadLine()) != null) { Console.WriteLine(line); linesCount += 1; } Assert.AreEqual(3, linesCount); } } }