diff options
| author | 2024-08-25 13:25:32 +0200 | |
|---|---|---|
| committer | 2024-08-25 13:25:32 +0200 | |
| commit | d3887bf6cc180118be9fc8a031cc3aefbfbeb668 (patch) | |
| tree | 122180a5289e99c0f92d5e998aaf182d210a700f | |
| parent | [bugfix] Carry-over `ApprovedByURI` to avoid marking already-approved remote ... (diff) | |
| download | gotosocial-d3887bf6cc180118be9fc8a031cc3aefbfbeb668.tar.xz | |
[bugfix] Let prometheus client do its own compression handling (#3232)
| -rw-r--r-- | cmd/gotosocial/action/server/server.go | 9 | ||||
| -rw-r--r-- | internal/api/metrics/metrics.go | 8 | ||||
| -rw-r--r-- | testrig/config.go | 2 | 
3 files changed, 14 insertions, 5 deletions
diff --git a/cmd/gotosocial/action/server/server.go b/cmd/gotosocial/action/server/server.go index c2c5e25cd..2ea48b7df 100644 --- a/cmd/gotosocial/action/server/server.go +++ b/cmd/gotosocial/action/server/server.go @@ -439,13 +439,18 @@ var Start action.GTSAction = func(ctx context.Context) error {  	fsThrottle := middleware.Throttle(cpuMultiplier, retryAfter) // fileserver / web templates / emojis  	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;  	// apply throttling *after* rate limiting  	authModule.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)  	fileserverModule.Route(route, fsMainLimit, fsThrottle)  	fileserverModule.RouteEmojis(route, instanceAccount.ID, fsEmojiLimit, fsThrottle) diff --git a/internal/api/metrics/metrics.go b/internal/api/metrics/metrics.go index d89e56ad5..af774d5e8 100644 --- a/internal/api/metrics/metrics.go +++ b/internal/api/metrics/metrics.go @@ -30,9 +30,13 @@ type Module struct {  }  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{ -		DisableCompression: true, +		OfferedCompressions: []promhttp.Compression{ +			promhttp.Identity, +			promhttp.Gzip, +		},  	}  	// Instrument handler itself. diff --git a/testrig/config.go b/testrig/config.go index 6a4254d61..673ed46b6 100644 --- a/testrig/config.go +++ b/testrig/config.go @@ -154,7 +154,7 @@ func testDefaults() config.Configuration {  		TracingTransport:         "grpc",  		TracingInsecureTransport: true, -		MetricsEnabled:     false, +		MetricsEnabled:     true,  		MetricsAuthEnabled: false,  		SyslogEnabled:  false,  | 
