improve the metrics console output (#2285)

This commit is contained in:
Reiley Yang 2021-08-25 15:39:12 -07:00 committed by GitHub
parent d9ad092dd3
commit 53a880fdd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 4 deletions

View File

@ -92,7 +92,12 @@ namespace OpenTelemetry.Exporter
bucketsBuilder.Append($"Sum: {histogramMetric.PopulationSum} Count: {histogramMetric.PopulationCount} \n");
foreach (var bucket in histogramMetric.Buckets)
{
bucketsBuilder.Append($"({bucket.LowBoundary} - {bucket.HighBoundary}) : {bucket.Count}");
bucketsBuilder.Append('(');
bucketsBuilder.Append(double.IsInfinity(bucket.LowBoundary) ? "-Infinity" : $"{bucket.LowBoundary}");
bucketsBuilder.Append(", ");
bucketsBuilder.Append(double.IsInfinity(bucket.HighBoundary) ? "+Infinity" : $"{bucket.HighBoundary}");
bucketsBuilder.Append(double.IsInfinity(bucket.HighBoundary) ? ')' : ']');
bucketsBuilder.Append($": {bucket.Count}");
bucketsBuilder.AppendLine();
}
@ -108,9 +113,16 @@ namespace OpenTelemetry.Exporter
}
}
string time = $"{metric.StartTimeExclusive.ToLocalTime().ToString("HH:mm:ss.fff")} {metric.EndTimeInclusive.ToLocalTime().ToString("HH:mm:ss.fff")}";
var msg = new StringBuilder($"Export {time} {metric.Name} [{string.Join(";", tags)}] {metric.MetricType}");
var msg = new StringBuilder($"Export (");
msg.Append(metric.StartTimeExclusive.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ", CultureInfo.InvariantCulture));
msg.Append(", ");
msg.Append(metric.EndTimeInclusive.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ", CultureInfo.InvariantCulture));
msg.Append("] ");
msg.Append(metric.Name);
msg.Append(' ');
msg.Append(string.Join(";", tags));
msg.Append(' ');
msg.Append(metric.MetricType);
if (!string.IsNullOrEmpty(metric.Description))
{