Compare commits

...

2 Commits

Author SHA1 Message Date
Vinícius Lourenço
3040b402d7 test(e2e): disable response compression on the e2e server 2026-12-02 09:26:20 -03:00
Vinícius Lourenço
08dea1fb8d feat(apiserver): add apiserver.compression.enabled 2026-12-02 09:26:19 -03:00
5 changed files with 68 additions and 4 deletions

View File

@@ -166,6 +166,9 @@ apiserver:
- /api/v1/version
- /
- /assets/
compression:
# Gzip responses on the fly. Turn off when a proxy in front already compresses.
enabled: true
##################### Querier #####################
querier:

View File

@@ -11,8 +11,9 @@ import (
// Config holds the configuration for config.
type Config struct {
httpserver.Config `mapstructure:",squash" yaml:",squash"`
Timeout Timeout `mapstructure:"timeout"`
Logging Logging `mapstructure:"logging"`
Timeout Timeout `mapstructure:"timeout"`
Logging Logging `mapstructure:"logging"`
Compression Compression `mapstructure:"compression"`
}
type Timeout struct {
@@ -29,6 +30,10 @@ type Logging struct {
ExcludedRoutes []string `mapstructure:"excluded_routes"`
}
type Compression struct {
Enabled bool `mapstructure:"enabled"`
}
func NewConfigFactory() factory.ConfigFactory {
return factory.NewConfigFactory(factory.MustNewName("apiserver"), newConfig)
}
@@ -56,6 +61,9 @@ func newConfig() factory.Config {
"/assets/",
},
},
Compression: Compression{
Enabled: true,
},
}
}

View File

@@ -68,7 +68,56 @@ func TestNewWithEnvProvider(t *testing.T) {
"/api/v1/health1",
},
},
Compression: Compression{
Enabled: true,
},
}
assert.Equal(t, expected, actual)
}
func TestCompressionWithEnvProvider(t *testing.T) {
testCases := []struct {
name string
env map[string]string
expected Compression
}{
{
name: "Defaults",
env: map[string]string{},
expected: Compression{Enabled: true},
},
{
name: "Disabled",
env: map[string]string{"SIGNOZ_APISERVER_COMPRESSION_ENABLED": "false"},
expected: Compression{Enabled: false},
},
{
name: "Disabled_Capitalized",
env: map[string]string{"SIGNOZ_APISERVER_COMPRESSION_ENABLED": "False"},
expected: Compression{Enabled: false},
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
for key, value := range testCase.env {
t.Setenv(key, value)
}
conf, err := config.New(
context.Background(),
config.ResolverConfig{
Uris: []string{"env:"},
ProviderFactories: []config.ProviderFactory{envprovider.NewFactory()},
},
[]factory.ConfigFactory{NewConfigFactory()},
)
require.NoError(t, err)
actual := &Config{}
require.NoError(t, conf.Unmarshal("apiserver", actual))
assert.Equal(t, testCase.expected, actual.Compression)
})
}
}

View File

@@ -338,7 +338,9 @@ func newProvider(
}
httpHandler := middleware.NewCors().Wrap(router)
httpHandler = middleware.NewCompress().Wrap(httpHandler)
if config.Compression.Enabled {
httpHandler = middleware.NewCompress().Wrap(httpHandler)
}
routePrefix := globalConfig.ExternalPath()
if routePrefix != "" {

View File

@@ -17,10 +17,12 @@ def e2e_env() -> dict:
"""Environment every e2e SigNoz gets. Each Playwright worker logs in once,
and the default cap of 5 sessions per user evicts the oldest, which turns a
worker's requests into 401s mid-run. Metrics reduction is off by default in
pkg/flagger/registry.go and the Volume Control specs need it."""
pkg/flagger/registry.go and the Volume Control specs need it. On-the-fly gzip
is slow in the -race build, so compression is off."""
return {
"SIGNOZ_TOKENIZER_OPAQUE_TOKEN_MAX__PER__USER": 100,
"SIGNOZ_FLAGGER_CONFIG_BOOLEAN_ENABLE__METRICS__REDUCTION": True,
"SIGNOZ_APISERVER_COMPRESSION_ENABLED": False,
}