diff --git a/cmd/agent/subcommands/run/command_windows.go b/cmd/agent/subcommands/run/command_windows.go index ae3b462c4cc44..e2bd81548cbf1 100644 --- a/cmd/agent/subcommands/run/command_windows.go +++ b/cmd/agent/subcommands/run/command_windows.go @@ -158,5 +158,8 @@ func getPlatformModules() fx.Option { return fx.Options( agentcrashdetect.Module, comptraceconfig.Module, + fx.Replace(comptraceconfig.Params{ + FailIfAPIKeyMissing: false, + }), ) } diff --git a/comp/trace/config/component.go b/comp/trace/config/component.go index febf35a006ed8..07175a802cf5e 100644 --- a/comp/trace/config/component.go +++ b/comp/trace/config/component.go @@ -50,9 +50,15 @@ type Mock interface { // Module defines the fx options for this component. var Module = fxutil.Component( fx.Provide(newConfig), + fx.Supply(Params{ + FailIfAPIKeyMissing: true, + }), ) // MockModule defines the fx options for the mock component. var MockModule = fxutil.Component( fx.Provide(newMock), + fx.Supply(Params{ + FailIfAPIKeyMissing: true, + }), ) diff --git a/comp/trace/config/config.go b/comp/trace/config/config.go index 23cab4bcf1305..867d630b51a58 100644 --- a/comp/trace/config/config.go +++ b/comp/trace/config/config.go @@ -24,7 +24,7 @@ import ( type dependencies struct { fx.In - + Params Params Config coreconfig.Component } @@ -43,8 +43,12 @@ type cfg struct { func newConfig(deps dependencies) (Component, error) { tracecfg, err := setupConfig(deps, "") + if err != nil { - return nil, err + // Allow main Agent to start with missing API key + if !(err == traceconfig.ErrMissingAPIKey && !deps.Params.FailIfAPIKeyMissing) { + return nil, err + } } c := cfg{ diff --git a/comp/trace/config/params.go b/comp/trace/config/params.go new file mode 100644 index 0000000000000..c6d72aceefe0b --- /dev/null +++ b/comp/trace/config/params.go @@ -0,0 +1,12 @@ +// 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 config + +// Params defines the parameters for the config component. +type Params struct { + // FailIfAPIKeyMissing controls if the Agent should fail if the API key is missing from the config. + FailIfAPIKeyMissing bool +}