diff --git a/docs/metrics/customizing-the-sdk/Program.cs b/docs/metrics/customizing-the-sdk/Program.cs index d19a12b9c..c8b08c3cc 100644 --- a/docs/metrics/customizing-the-sdk/Program.cs +++ b/docs/metrics/customizing-the-sdk/Program.cs @@ -36,9 +36,12 @@ public class Program // Rename an instrument to new name. .AddView(instrumentName: "MyCounter", name: "MyCounterRenamed") - // Change Histogram boundaries + // Change Histogram boundaries using the Explicit Bucket Histogram aggregation. .AddView(instrumentName: "MyHistogram", new ExplicitBucketHistogramConfiguration() { Boundaries = new double[] { 10, 20 } }) + // Change Histogram to use the Base2 Exponential Bucket Histogram aggregation. + .AddView(instrumentName: "MyExponentialBucketHistogram", new Base2ExponentialBucketHistogramConfiguration()) + // For the instrument "MyCounterCustomTags", aggregate with only the keys "tag1", "tag2". .AddView(instrumentName: "MyCounterCustomTags", new MetricStreamConfiguration() { TagKeys = new string[] { "tag1", "tag2" } }) @@ -81,6 +84,12 @@ public class Program histogram.Record(random.Next(1, 1000), new("tag1", "value1"), new("tag2", "value2")); } + var exponentialBucketHistogram = Meter1.CreateHistogram("MyExponentialBucketHistogram"); + for (int i = 0; i < 20000; i++) + { + exponentialBucketHistogram.Record(random.Next(1, 1000), new("tag1", "value1"), new("tag2", "value2")); + } + var counterCustomTags = Meter1.CreateCounter("MyCounterCustomTags"); for (int i = 0; i < 20000; i++) {