[bugfix] Let prometheus client do its own compression handling (#3232)

This commit is contained in:
tobi 2024-08-25 13:25:32 +02:00 committed by GitHub
parent bef0dfc66c
commit d3887bf6cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 5 deletions

View file

@ -439,13 +439,18 @@ func(context.Context, time.Time) {
fsThrottle := middleware.Throttle(cpuMultiplier, retryAfter) // fileserver / web templates / emojis fsThrottle := middleware.Throttle(cpuMultiplier, retryAfter) // fileserver / web templates / emojis
pkThrottle := middleware.Throttle(cpuMultiplier, retryAfter) // throttle public key endpoint separately pkThrottle := middleware.Throttle(cpuMultiplier, retryAfter) // throttle public key endpoint separately
gzip := middleware.Gzip() // applied to all except fileserver // Gzip middleware is applied to all endpoints except
// fileserver (compression too expensive for those),
// health (which really doesn't need compression), and
// metrics (which does its own compression handling that
// is rather annoying to neatly override).
gzip := middleware.Gzip()
// these should be routed in order; // these should be routed in order;
// apply throttling *after* rate limiting // apply throttling *after* rate limiting
authModule.Route(route, clLimit, clThrottle, gzip) authModule.Route(route, clLimit, clThrottle, gzip)
clientModule.Route(route, clLimit, clThrottle, gzip) clientModule.Route(route, clLimit, clThrottle, gzip)
metricsModule.Route(route, clLimit, clThrottle, gzip) metricsModule.Route(route, clLimit, clThrottle)
healthModule.Route(route, clLimit, clThrottle) healthModule.Route(route, clLimit, clThrottle)
fileserverModule.Route(route, fsMainLimit, fsThrottle) fileserverModule.Route(route, fsMainLimit, fsThrottle)
fileserverModule.RouteEmojis(route, instanceAccount.ID, fsEmojiLimit, fsThrottle) fileserverModule.RouteEmojis(route, instanceAccount.ID, fsEmojiLimit, fsThrottle)

View file

@ -30,9 +30,13 @@ type Module struct {
} }
func New() *Module { func New() *Module {
// Use our own gzip handler. // Let prometheus use "identity", ie., no compression,
// or "gzip", to match our own gzip compression middleware.
opts := promhttp.HandlerOpts{ opts := promhttp.HandlerOpts{
DisableCompression: true, OfferedCompressions: []promhttp.Compression{
promhttp.Identity,
promhttp.Gzip,
},
} }
// Instrument handler itself. // Instrument handler itself.

View file

@ -154,7 +154,7 @@ func testDefaults() config.Configuration {
TracingTransport: "grpc", TracingTransport: "grpc",
TracingInsecureTransport: true, TracingInsecureTransport: true,
MetricsEnabled: false, MetricsEnabled: true,
MetricsAuthEnabled: false, MetricsAuthEnabled: false,
SyslogEnabled: false, SyslogEnabled: false,