From 5b5f0df177e3571a9710f01028fb4c876ecc2a28 Mon Sep 17 00:00:00 2001 From: Robert Coltheart Date: Fri, 1 Dec 2023 09:06:53 +1100 Subject: [PATCH] Add tests --- .../PrometheusCollectionManagerTests.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs index 471addf374..7d8347cc47 100644 --- a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs +++ b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs @@ -24,11 +24,13 @@ namespace OpenTelemetry.Exporter.Prometheus.Tests; public sealed class PrometheusCollectionManagerTests { [Theory] - [InlineData(0)] // disable cache, default value for HttpListener + [InlineData(0, true)] // disable cache, default value for HttpListener + [InlineData(0, false)] // disable cache, default value for HttpListener #if PROMETHEUS_ASPNETCORE - [InlineData(300)] // default value for AspNetCore, no possibility to set on HttpListener + [InlineData(300, true)] // default value for AspNetCore, no possibility to set on HttpListener + [InlineData(300, false)] // default value for AspNetCore, no possibility to set on HttpListener #endif - public async Task EnterExitCollectTest(int scrapeResponseCacheDurationMilliseconds) + public async Task EnterExitCollectTest(int scrapeResponseCacheDurationMilliseconds, bool requestOpenMetrics) { bool cacheEnabled = scrapeResponseCacheDurationMilliseconds != 0; using var meter = new Meter(Utils.GetCurrentMethodName()); @@ -65,7 +67,7 @@ public async Task EnterExitCollectTest(int scrapeResponseCacheDurationMillisecon { collectTasks[i] = Task.Run(async () => { - var response = await exporter.CollectionManager.EnterCollect(false); + var response = await exporter.CollectionManager.EnterCollect(requestOpenMetrics); try { return new Response @@ -98,7 +100,7 @@ public async Task EnterExitCollectTest(int scrapeResponseCacheDurationMillisecon counter.Add(100); // This should use the cache and ignore the second counter update. - var task = exporter.CollectionManager.EnterCollect(false); + var task = exporter.CollectionManager.EnterCollect(requestOpenMetrics); Assert.True(task.IsCompleted); var response = await task; try @@ -129,7 +131,7 @@ public async Task EnterExitCollectTest(int scrapeResponseCacheDurationMillisecon { collectTasks[i] = Task.Run(async () => { - var response = await exporter.CollectionManager.EnterCollect(false); + var response = await exporter.CollectionManager.EnterCollect(requestOpenMetrics); try { return new Response