Skip to content

Commit

Permalink
fix: Add workaround for prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 committed Apr 14, 2024
1 parent d1f5c51 commit 5364a89
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/GZCTF/Extensions/TelemetryExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,24 @@ public static void UseTelemetry(this IApplicationBuilder app, TelemetryConfig? c
if (config is not { Enable: true, Prometheus.Enable: true })
return;


if (config.Prometheus.Port is { } port)
app.UseOpenTelemetryPrometheusScrapingEndpoint(context => context.Connection.LocalPort == port);
app.UseOpenTelemetryPrometheusScrapingEndpoint(context =>
{
if (context.Connection.LocalPort == port)
{
// FIXME: workaround for prometheus
context.Request.Headers.Accept = "application/openmetrics-text";
return true;
}

return false;
});
else
app.UseOpenTelemetryPrometheusScrapingEndpoint();
app.UseOpenTelemetryPrometheusScrapingEndpoint(context =>
{
// FIXME: workaround for prometheus
context.Request.Headers.Accept = "application/openmetrics-text";
return true;
});
}
}
}

0 comments on commit 5364a89

Please sign in to comment.