From c31d69dd20a726e5e81dff4bb1f6c908e3d0b6ab Mon Sep 17 00:00:00 2001 From: Raj Nishtala Date: Wed, 16 Oct 2024 15:26:09 -0400 Subject: [PATCH] fix(compression): Changes that follow core breaking changes to the confighttp API --- exporter/splunkhecexporter/client.go | 3 ++- pkg/datadog/config/config.go | 2 +- pkg/datadog/config/config_test.go | 3 ++- testbed/testbed/senders.go | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/exporter/splunkhecexporter/client.go b/exporter/splunkhecexporter/client.go index 3e63487840d5..d0b70d3db0ce 100644 --- a/exporter/splunkhecexporter/client.go +++ b/exporter/splunkhecexporter/client.go @@ -14,6 +14,7 @@ import ( "github.com/goccy/go-json" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config/configcompression" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/pdata/plog" @@ -658,7 +659,7 @@ func checkHecHealth(ctx context.Context, client *http.Client, healthCheckURL *ur func buildHTTPClient(ctx context.Context, config *Config, host component.Host, telemetrySettings component.TelemetrySettings) (*http.Client, error) { // we handle compression explicitly. - config.ClientConfig.Compression = "" + config.ClientConfig.Compression = configcompression.TypeWithLevel{Type: "", Level: 0} return config.ToClient(ctx, host, telemetrySettings) } diff --git a/pkg/datadog/config/config.go b/pkg/datadog/config/config.go index 60542c785993..5372b4b09a7f 100644 --- a/pkg/datadog/config/config.go +++ b/pkg/datadog/config/config.go @@ -144,7 +144,7 @@ func validateClientConfig(cfg confighttp.ClientConfig) error { if cfg.Endpoint != "" { unsupported = append(unsupported, "endpoint") } - if cfg.Compression != "" { + if cfg.Compression.Type != "" { unsupported = append(unsupported, "compression") } if len(cfg.Headers) > 0 { diff --git a/pkg/datadog/config/config_test.go b/pkg/datadog/config/config_test.go index d19d51826922..43f17869970b 100644 --- a/pkg/datadog/config/config_test.go +++ b/pkg/datadog/config/config_test.go @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config/configauth" + "go.opentelemetry.io/collector/config/configcompression" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/config/confignet" "go.opentelemetry.io/collector/config/configopaque" @@ -163,7 +164,7 @@ func TestValidate(t *testing.T) { API: APIConfig{Key: "notnull"}, ClientConfig: confighttp.ClientConfig{ Endpoint: "endpoint", - Compression: "gzip", + Compression: configcompression.TypeWithLevel{Type: configcompression.TypeGzip, Level: -1}, Auth: &auth, Headers: map[string]configopaque.String{"key": "val"}, HTTP2ReadIdleTimeout: 250, diff --git a/testbed/testbed/senders.go b/testbed/testbed/senders.go index abe930baf645..b5fd02dca8e3 100644 --- a/testbed/testbed/senders.go +++ b/testbed/testbed/senders.go @@ -78,7 +78,7 @@ func (dsb *DataSenderBase) Flush() { type otlpHTTPDataSender struct { DataSenderBase - compression configcompression.Type + compression configcompression.TypeWithLevel } func (ods *otlpHTTPDataSender) fillConfig(cfg *otlphttpexporter.Config) *otlphttpexporter.Config {