diff --git a/src/GZCTF/Extensions/TelemetryExtension.cs b/src/GZCTF/Extensions/TelemetryExtension.cs index 0f644a5db..bdae132ec 100644 --- a/src/GZCTF/Extensions/TelemetryExtension.cs +++ b/src/GZCTF/Extensions/TelemetryExtension.cs @@ -74,7 +74,11 @@ public static void UseTelemetry(this IApplicationBuilder app, TelemetryConfig? c if (config.Prometheus.Port is { } port) app.UseOpenTelemetryPrometheusScrapingEndpoint(context => { - if (context.Connection.LocalPort == port) + if (context.Connection.LocalPort == port + && string.Equals( + context.Request.Path.ToString().TrimEnd('/'), + "/metrics", + StringComparison.OrdinalIgnoreCase)) { // FIXME: workaround for prometheus context.Request.Headers.Accept = "application/openmetrics-text"; @@ -86,9 +90,17 @@ public static void UseTelemetry(this IApplicationBuilder app, TelemetryConfig? c else app.UseOpenTelemetryPrometheusScrapingEndpoint(context => { - // FIXME: workaround for prometheus - context.Request.Headers.Accept = "application/openmetrics-text"; - return true; + if (string.Equals( + context.Request.Path.ToString().TrimEnd('/'), + "/metrics", + StringComparison.OrdinalIgnoreCase)) + { + // FIXME: workaround for prometheus + context.Request.Headers.Accept = "application/openmetrics-text"; + return true; + } + + return false; }); } }