diff options
| author | JP Dillingham <jp@dillingham.me> | 2024-11-17 16:25:00 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-17 16:25:00 -0600 |
| commit | 37bf3636d383fe3fd4f5f4daa4365399830df4f2 (patch) | |
| tree | eaa9a0056190f823310295a11745e6d473bfd30a /src | |
| parent | d6d4eddeac1cc89940def8fa0219ed706d9c1eee (diff) | |
| parent | f769362146496925aaa8cf4f99d603a3a86a7b96 (diff) | |
| download | slskd-37bf3636d383fe3fd4f5f4daa4365399830df4f2.tar.gz | |
Merge pull request #1245 from slskd/prometheus
Include Content-Type header when returning Prometheus metrics via /metrics
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Program.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 08d03cc5..b302cc8c 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -949,6 +949,10 @@ namespace slskd endpoints.MapGet(url, async context => { + // at the time of writing, the prometheus library doesn't include a way to add authentication + // to the UseMetricServer() middleware. this is most likely a consequence of me mixing + // and matching minimal API stuff with controllers. if i ever straighten that out, + // this should be revisited. if (!options.Authentication.Disabled) { var auth = context.Request.Headers["Authorization"].FirstOrDefault(); @@ -964,8 +968,10 @@ namespace slskd } } - var response = await Metrics.BuildAsync(); - await context.Response.WriteAsync(response); + var metricsAsText = await Metrics.BuildAsync(); + + context.Response.Headers.Append("Content-Type", "text/plain; version=0.0.4; charset=utf-8"); + await context.Response.WriteAsync(metricsAsText); }); } }); |
