Benchmarks for metrics modified to have a metric reader (#4974)

This commit is contained in:
Cijo Thomas 2023-10-24 10:33:31 -07:00 committed by GitHub
parent faa70be1b3
commit 637ddcfe4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -139,9 +139,14 @@ public class AspNetCoreInstrumentationNewBenchmarks
this.StartWebApplication();
this.httpClient = new HttpClient();
var exportedItems = new List<Metric>();
this.meterProvider = Sdk.CreateMeterProviderBuilder()
.ConfigureServices(services => services.AddSingleton<IConfiguration>(configuration))
.AddAspNetCoreInstrumentation()
.AddInMemoryExporter(exportedItems, metricReaderOptions =>
{
metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000;
})
.Build();
}
else if (this.EnableInstrumentation.HasFlag(EnableInstrumentationOption.Traces) &&
@ -155,9 +160,14 @@ public class AspNetCoreInstrumentationNewBenchmarks
.AddAspNetCoreInstrumentation()
.Build();
var exportedItems = new List<Metric>();
this.meterProvider = Sdk.CreateMeterProviderBuilder()
.ConfigureServices(services => services.AddSingleton<IConfiguration>(configuration))
.AddAspNetCoreInstrumentation()
.AddInMemoryExporter(exportedItems, metricReaderOptions =>
{
metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000;
})
.Build();
}
}

View File

@ -92,8 +92,13 @@ public class HttpClientInstrumentationBenchmarks
this.StartWebApplication();
this.httpClient = new HttpClient();
var exportedItems = new List<Metric>();
this.meterProvider = Sdk.CreateMeterProviderBuilder()
.AddHttpClientInstrumentation()
.AddInMemoryExporter(exportedItems, metricReaderOptions =>
{
metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000;
})
.Build();
}
else if (this.EnableInstrumentation.HasFlag(EnableInstrumentationOption.Traces) &&
@ -106,8 +111,13 @@ public class HttpClientInstrumentationBenchmarks
.AddHttpClientInstrumentation()
.Build();
var exportedItems = new List<Metric>();
this.meterProvider = Sdk.CreateMeterProviderBuilder()
.AddHttpClientInstrumentation()
.AddInMemoryExporter(exportedItems, metricReaderOptions =>
{
metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000;
})
.Build();
}
}