Update example app demonstrating exponential histogram configuration (#4530)

This commit is contained in:
Alan West 2023-05-31 11:33:54 -07:00 committed by GitHub
parent 0b816319ac
commit d89af8537e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -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<long>("MyExponentialBucketHistogram");
for (int i = 0; i < 20000; i++)
{
exponentialBucketHistogram.Record(random.Next(1, 1000), new("tag1", "value1"), new("tag2", "value2"));
}
var counterCustomTags = Meter1.CreateCounter<long>("MyCounterCustomTags");
for (int i = 0; i < 20000; i++)
{