mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 00:40:25 +02:00
metrics: explicitly set Accept header (#4774)
If a request is made to the Pomerium metrics endpoint with an Accept header requesting the Prometheus protobuf exposition format, some metrics will be missing from the response. These missing metrics are obtained by replaying the incoming request to an OpenCensus metrics exporter. This exporter honors the request for the protobuf format, however Pomerium expects this response to be in the text format. We can avoid this mismatch by explicitly requesting the text format from the OpenCensus exporter, regardless of the incoming request's Accept header. (Note: the Pomerium metrics endpoint always responds with text format metrics, even if the protobuf format is requested.)
This commit is contained in:
parent
e49fbf58fa
commit
a246466a87
2 changed files with 23 additions and 3 deletions
|
@ -196,6 +196,8 @@ func ocExport(name string, exporter *ocprom.Exporter, r *http.Request, labels []
|
|||
return func(context.Context) promProducerResult {
|
||||
// Ensure we don't get entangled with compression from ocprom
|
||||
r.Header.Del("Accept-Encoding")
|
||||
// Request metrics in text format.
|
||||
r.Header.Set("Accept", "text/plain")
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
exporter.ServeHTTP(rec, r)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue