diff --git a/comp/otelcol/ddflareextension/impl/server.go b/comp/otelcol/ddflareextension/impl/server.go index 4b3c0fcf0c104f..0772ce4b15d32e 100644 --- a/comp/otelcol/ddflareextension/impl/server.go +++ b/comp/otelcol/ddflareextension/impl/server.go @@ -112,7 +112,9 @@ func newServer(endpoint string, handler http.Handler) (*server, error) { r := mux.NewRouter() r.Handle("/", handler) - r.Use(validateToken) + if util.GetAuthToken() != "" { + r.Use(validateToken) + } s := &http.Server{ Addr: endpoint, diff --git a/test/new-e2e/tests/otel/otel-agent/config/no-dd-exporter.yml b/test/new-e2e/tests/otel/otel-agent/config/no-dd-exporter.yml new file mode 100644 index 00000000000000..3c008992c3d06f --- /dev/null +++ b/test/new-e2e/tests/otel/otel-agent/config/no-dd-exporter.yml @@ -0,0 +1,23 @@ +receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + http: + endpoint: 0.0.0.0:4318 + +exporters: + debug: + verbosity: detailed + +service: + pipelines: + metrics: + receivers: [otlp] + exporters: [debug] + traces: + receivers: [otlp] + exporters: [debug] + logs: + receivers: [otlp] + exporters: [debug] diff --git a/test/new-e2e/tests/otel/otel-agent/no_dd_exporter_test.go b/test/new-e2e/tests/otel/otel-agent/no_dd_exporter_test.go new file mode 100644 index 00000000000000..10c1bce4d2319e --- /dev/null +++ b/test/new-e2e/tests/otel/otel-agent/no_dd_exporter_test.go @@ -0,0 +1,62 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2016-present Datadog, Inc. + +// Package otelagent contains e2e otel agent tests +package otelagent + +import ( + _ "embed" + "testing" + + "github.com/DataDog/test-infra-definitions/components/datadog/kubernetesagentparams" + + "github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e" + "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments" + awskubernetes "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments/aws/kubernetes" + "github.com/DataDog/datadog-agent/test/new-e2e/tests/otel/utils" +) + +type noDDExporterTestSuite struct { + e2e.BaseSuite[environments.Kubernetes] +} + +//go:embed config/no-dd-exporter.yml +var noDDExporterConfig string + +func TestOTelAgentWithNoDDExporter(t *testing.T) { + values := ` +datadog: + logs: + containerCollectAll: false + containerCollectUsingFiles: false +` + t.Parallel() + e2e.Run(t, &noDDExporterTestSuite{}, + e2e.WithProvisioner( + awskubernetes.KindProvisioner( + awskubernetes.WithAgentOptions( + kubernetesagentparams.WithoutDualShipping(), + kubernetesagentparams.WithHelmValues(values), + kubernetesagentparams.WithOTelAgent(), + kubernetesagentparams.WithOTelConfig(noDDExporterConfig), + )))) +} + +func (s *noDDExporterTestSuite) TestOTelAgentInstalled() { + utils.TestOTelAgentInstalled(s) +} + +func (s *noDDExporterTestSuite) TestFlare() { + expectedContents := []string{ + "otel-agent", + "ddflare/dd-autoconfigured:", + "health_check/dd-autoconfigured:", + "pprof/dd-autoconfigured:", + "zpages/dd-autoconfigured:", + "infraattributes/dd-autoconfigured:", + "prometheus/dd-autoconfigured:", + } + utils.TestOTelFlare(s, expectedContents) +}