diff --git a/src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs b/src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs index fc9d13de06b..25654d7122b 100644 --- a/src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs +++ b/src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs @@ -146,8 +146,21 @@ public override ExportResult Export(in Batch batch) } else { - // TODO: Consider how/if to display buckets for exponential histograms. - bucketsBuilder.AppendLine("Buckets are not displayed for exponential histograms."); + var exponentialHistogramData = metricPoint.GetExponentialHistogramData(); + var scale = exponentialHistogramData.Scale; + + if (exponentialHistogramData.ZeroCount != 0) + { + bucketsBuilder.AppendLine($"Zero Bucket:{exponentialHistogramData.ZeroCount}"); + } + + var offset = exponentialHistogramData.PositiveBuckets.Offset; + foreach (var bucketCount in exponentialHistogramData.PositiveBuckets) + { + var lowerBound = Base2ExponentialBucketHistogram.LowerBoundary(offset, scale).ToString(CultureInfo.InvariantCulture); + var upperBound = Base2ExponentialBucketHistogram.LowerBoundary(++offset, scale).ToString(CultureInfo.InvariantCulture); + bucketsBuilder.AppendLine($"({lowerBound}, {upperBound}]:{bucketCount}"); + } } valueDisplay = bucketsBuilder.ToString(); diff --git a/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj b/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj index 7883a6a6ce4..b7afb8a8fab 100644 --- a/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj +++ b/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj @@ -28,6 +28,7 @@ +