Update MetricView benchmarks (#2647)

This commit is contained in:
Utkarsh Umesan Pillai 2021-11-19 17:17:18 -08:00 committed by GitHub
parent 3a516f3357
commit b16348ffe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -20,6 +20,7 @@ using System.Diagnostics.Metrics;
using System.Threading;
using BenchmarkDotNet.Attributes;
using OpenTelemetry;
using OpenTelemetry.Exporter;
using OpenTelemetry.Metrics;
using OpenTelemetry.Tests;
@ -46,6 +47,7 @@ namespace Benchmarks.Metrics
private static readonly ThreadLocal<Random> ThreadLocalRandom = new ThreadLocal<Random>(() => new Random());
private static readonly string[] DimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" };
private static readonly int DimensionsValuesLength = DimensionValues.Length;
private List<Metric> metrics;
private Counter<long> counter;
private MeterProvider provider;
private Meter meter;
@ -81,11 +83,13 @@ namespace Benchmarks.Metrics
{
this.meter = new Meter(Utils.GetCurrentMethodName());
this.counter = this.meter.CreateCounter<long>("counter");
this.metrics = new List<Metric>();
if (this.ViewConfig == ViewConfiguration.NoView)
{
this.provider = Sdk.CreateMeterProviderBuilder()
.AddMeter(this.meter.Name)
.AddReader(new BaseExportingMetricReader(new InMemoryExporter<Metric>(this.metrics)))
.Build();
}
else if (this.ViewConfig == ViewConfiguration.ViewNoInstrSelect)
@ -93,6 +97,7 @@ namespace Benchmarks.Metrics
this.provider = Sdk.CreateMeterProviderBuilder()
.AddMeter(this.meter.Name)
.AddView("nomatch", new MetricStreamConfiguration() { TagKeys = new string[] { "DimName1", "DimName2", "DimName3" } })
.AddReader(new BaseExportingMetricReader(new InMemoryExporter<Metric>(this.metrics)))
.Build();
}
else if (this.ViewConfig == ViewConfiguration.ViewSelectsInstr)
@ -100,6 +105,7 @@ namespace Benchmarks.Metrics
this.provider = Sdk.CreateMeterProviderBuilder()
.AddMeter(this.meter.Name)
.AddView(this.counter.Name, new MetricStreamConfiguration() { TagKeys = new string[] { "DimName1", "DimName2", "DimName3" } })
.AddReader(new BaseExportingMetricReader(new InMemoryExporter<Metric>(this.metrics)))
.Build();
}
}