diff --git a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs index 223ed4d8c00..72145bdaed2 100644 --- a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs +++ b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs @@ -117,6 +117,14 @@ private static bool AcceptsOpenMetrics(HttpRequest request) return false; } - return acceptHeader.Any(PrometheusHeadersParser.AcceptsOpenMetrics); + foreach (var header in acceptHeader) + { + if (PrometheusHeadersParser.AcceptsOpenMetrics(header)) + { + return true; + } + } + + return false; } }