From 637ddcfe4cac91e70dba82859ecf958272aa1d4b Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 24 Oct 2023 10:33:31 -0700 Subject: [PATCH] Benchmarks for metrics modified to have a metric reader (#4974) --- .../AspNetCoreInstrumentationNewBenchmarks.cs | 10 ++++++++++ .../HttpClientInstrumentationBenchmarks.cs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/test/Benchmarks/Instrumentation/AspNetCoreInstrumentationNewBenchmarks.cs b/test/Benchmarks/Instrumentation/AspNetCoreInstrumentationNewBenchmarks.cs index 1adb679d8f..13e41f0d2b 100644 --- a/test/Benchmarks/Instrumentation/AspNetCoreInstrumentationNewBenchmarks.cs +++ b/test/Benchmarks/Instrumentation/AspNetCoreInstrumentationNewBenchmarks.cs @@ -139,9 +139,14 @@ public void GetRequestForAspNetCoreAppGlobalSetup() this.StartWebApplication(); this.httpClient = new HttpClient(); + var exportedItems = new List(); this.meterProvider = Sdk.CreateMeterProviderBuilder() .ConfigureServices(services => services.AddSingleton(configuration)) .AddAspNetCoreInstrumentation() + .AddInMemoryExporter(exportedItems, metricReaderOptions => + { + metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000; + }) .Build(); } else if (this.EnableInstrumentation.HasFlag(EnableInstrumentationOption.Traces) && @@ -155,9 +160,14 @@ public void GetRequestForAspNetCoreAppGlobalSetup() .AddAspNetCoreInstrumentation() .Build(); + var exportedItems = new List(); this.meterProvider = Sdk.CreateMeterProviderBuilder() .ConfigureServices(services => services.AddSingleton(configuration)) .AddAspNetCoreInstrumentation() + .AddInMemoryExporter(exportedItems, metricReaderOptions => + { + metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000; + }) .Build(); } } diff --git a/test/Benchmarks/Instrumentation/HttpClientInstrumentationBenchmarks.cs b/test/Benchmarks/Instrumentation/HttpClientInstrumentationBenchmarks.cs index c58dbb013c..530dedfd80 100644 --- a/test/Benchmarks/Instrumentation/HttpClientInstrumentationBenchmarks.cs +++ b/test/Benchmarks/Instrumentation/HttpClientInstrumentationBenchmarks.cs @@ -92,8 +92,13 @@ public void HttpClientRequestGlobalSetup() this.StartWebApplication(); this.httpClient = new HttpClient(); + var exportedItems = new List(); 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 void HttpClientRequestGlobalSetup() .AddHttpClientInstrumentation() .Build(); + var exportedItems = new List(); this.meterProvider = Sdk.CreateMeterProviderBuilder() .AddHttpClientInstrumentation() + .AddInMemoryExporter(exportedItems, metricReaderOptions => + { + metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000; + }) .Build(); } }