From d9446b4adef7fe270accafcae216cb97d402aa75 Mon Sep 17 00:00:00 2001 From: Olivier G Date: Wed, 29 Nov 2023 11:46:19 +0100 Subject: [PATCH 1/7] Migrate comp/core to new file hierarchy --- comp/core/log/component.go | 37 ------------- comp/core/log/component_mock.go | 15 +++++ comp/core/log/{ => logimpl}/logger.go | 61 +++++++++++++-------- comp/core/log/{ => logimpl}/logger_test.go | 5 +- comp/core/log/{ => logimpl}/mock.go | 24 ++++++-- comp/core/log/{ => logimpl}/mock_test.go | 5 +- comp/core/log/{ => logimpl}/params.go | 2 +- comp/core/log/{ => logimpl}/params_test.go | 2 +- comp/core/log/{ => logimpl}/trace_logger.go | 39 +++++++------ tasks/components.py | 1 - 10 files changed, 102 insertions(+), 89 deletions(-) create mode 100644 comp/core/log/component_mock.go rename comp/core/log/{ => logimpl}/logger.go (66%) rename comp/core/log/{ => logimpl}/logger_test.go (82%) rename comp/core/log/{ => logimpl}/mock.go (70%) rename comp/core/log/{ => logimpl}/mock_test.go (82%) rename comp/core/log/{ => logimpl}/params.go (99%) rename comp/core/log/{ => logimpl}/params_test.go (99%) rename comp/core/log/{ => logimpl}/trace_logger.go (67%) diff --git a/comp/core/log/component.go b/comp/core/log/component.go index e32a84cad9494..17cb1eab14904 100644 --- a/comp/core/log/component.go +++ b/comp/core/log/component.go @@ -14,12 +14,6 @@ // logging output to `t.Log(..)`, for ease of investigation when a test fails. package log -import ( - "go.uber.org/fx" - - "github.com/DataDog/datadog-agent/pkg/util/fxutil" -) - // team: agent-shared-components // Component is the component type. @@ -63,34 +57,3 @@ type Component interface { // Flush will flush the contents of the logs to the sinks Flush() } - -// Mock is the mocked component type. -type Mock interface { - Component - - // no further methods are defined. -} - -// Module defines the fx options for this component. -var Module fx.Option = fxutil.Component( - fx.Provide(newAgentLogger), -) - -// TraceModule defines the fx options for this component in its Trace variant. -// -// TODO(components): move this comp/trace; that component shall implement the -// -// log.Component interface. -var TraceModule fx.Option = fxutil.Component( - fx.Provide(newTraceLogger), -) - -// MockModule defines the fx options for the mock component. -var MockModule fx.Option = fxutil.Component( - fx.Provide(newMockLogger), -) - -// TraceMockModule defines the fx options for the mock component in its Trace variant. -var TraceMockModule fx.Option = fxutil.Component( - fx.Provide(newTraceMockLogger), -) diff --git a/comp/core/log/component_mock.go b/comp/core/log/component_mock.go new file mode 100644 index 0000000000000..afdf54ce4e470 --- /dev/null +++ b/comp/core/log/component_mock.go @@ -0,0 +1,15 @@ +// 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. + +//go:build test + +package log + +// Mock is the mocked component type. +type Mock interface { + Component + + // no further methods are defined. +} diff --git a/comp/core/log/logger.go b/comp/core/log/logimpl/logger.go similarity index 66% rename from comp/core/log/logger.go rename to comp/core/log/logimpl/logger.go index 797ad29d1a5a2..8e77eab63e7a8 100644 --- a/comp/core/log/logger.go +++ b/comp/core/log/logimpl/logger.go @@ -3,7 +3,8 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -package log +// Package logimpl implements a component to handle logging internal to the agent. +package logimpl import ( "context" @@ -14,8 +15,24 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log" pkgconfiglogs "github.com/DataDog/datadog-agent/pkg/config/logs" - "github.com/DataDog/datadog-agent/pkg/util/log" + "github.com/DataDog/datadog-agent/pkg/util/fxutil" + pkglog "github.com/DataDog/datadog-agent/pkg/util/log" +) + +// Module defines the fx options for this component. +var Module fx.Option = fxutil.Component( + fx.Provide(newAgentLogger), +) + +// TraceModule defines the fx options for this component in its Trace variant. +// +// TODO(components): move this comp/trace; that component shall implement the +// +// log.Component interface. +var TraceModule fx.Option = fxutil.Component( + fx.Provide(newTraceLogger), ) // logger implements the component @@ -36,16 +53,16 @@ type logger struct { // - You add few logging functions. // - When the instance of logger.Component is reachable in less than 5 stack frames. // - It doesn't make the migration to log.Component easier. -func NewTemporaryLoggerWithoutInit() Component { +func NewTemporaryLoggerWithoutInit() log.Component { return &logger{} } -func newAgentLogger(lc fx.Lifecycle, params Params, config config.Component) (Component, error) { +func newAgentLogger(lc fx.Lifecycle, params Params, config config.Component) (log.Component, error) { return NewLogger(lc, params, config) } // NewLogger creates a log.Component using the provided config.LogConfig -func NewLogger(lc fx.Lifecycle, params Params, config config.LogConfig) (Component, error) { +func NewLogger(lc fx.Lifecycle, params Params, config config.LogConfig) (log.Component, error) { if params.logLevelFn == nil { return nil, errors.New("must call one of core.BundleParams.ForOneShot or ForDaemon") } @@ -72,75 +89,75 @@ func NewLogger(lc fx.Lifecycle, params Params, config config.LogConfig) (Compone return l, nil } -// Until the log migration to component is done, we use *StackDepth to log. The log component add 1 layer to the call +// Until the log migration to component is done, we use *StackDepth to pkglog. The log component add 1 layer to the call // stack and *StackDepth add another. // // We check the current log level to avoid calling Sprintf when it's not needed (Sprintf from Tracef uses a lot a CPU) // Trace implements Component#Trace. -func (*logger) Trace(v ...interface{}) { log.TraceStackDepth(2, v...) } +func (*logger) Trace(v ...interface{}) { pkglog.TraceStackDepth(2, v...) } // Tracef implements Component#Tracef. func (*logger) Tracef(format string, params ...interface{}) { - currentLevel, _ := log.GetLogLevel() + currentLevel, _ := pkglog.GetLogLevel() if currentLevel <= seelog.TraceLvl { - log.TraceStackDepth(2, fmt.Sprintf(format, params...)) + pkglog.TraceStackDepth(2, fmt.Sprintf(format, params...)) } } // Debug implements Component#Debug. -func (*logger) Debug(v ...interface{}) { log.DebugStackDepth(2, v...) } +func (*logger) Debug(v ...interface{}) { pkglog.DebugStackDepth(2, v...) } // Debugf implements Component#Debugf. func (*logger) Debugf(format string, params ...interface{}) { - currentLevel, _ := log.GetLogLevel() + currentLevel, _ := pkglog.GetLogLevel() if currentLevel <= seelog.DebugLvl { - log.DebugStackDepth(2, fmt.Sprintf(format, params...)) + pkglog.DebugStackDepth(2, fmt.Sprintf(format, params...)) } } // Info implements Component#Info. -func (*logger) Info(v ...interface{}) { log.InfoStackDepth(2, v...) } +func (*logger) Info(v ...interface{}) { pkglog.InfoStackDepth(2, v...) } // Infof implements Component#Infof. func (*logger) Infof(format string, params ...interface{}) { - currentLevel, _ := log.GetLogLevel() + currentLevel, _ := pkglog.GetLogLevel() if currentLevel <= seelog.InfoLvl { - log.InfoStackDepth(2, fmt.Sprintf(format, params...)) + pkglog.InfoStackDepth(2, fmt.Sprintf(format, params...)) } } // Warn implements Component#Warn. -func (*logger) Warn(v ...interface{}) error { return log.WarnStackDepth(2, v...) } +func (*logger) Warn(v ...interface{}) error { return pkglog.WarnStackDepth(2, v...) } // Warnf implements Component#Warnf. func (*logger) Warnf(format string, params ...interface{}) error { // no need to check the current log level since Sprintf will be called in all case to generate the returned // error - return log.WarnStackDepth(2, fmt.Sprintf(format, params...)) + return pkglog.WarnStackDepth(2, fmt.Sprintf(format, params...)) } // Error implements Component#Error. -func (*logger) Error(v ...interface{}) error { return log.ErrorStackDepth(2, v...) } +func (*logger) Error(v ...interface{}) error { return pkglog.ErrorStackDepth(2, v...) } // Errorf implements Component#Errorf. func (*logger) Errorf(format string, params ...interface{}) error { // no need to check the current log level since Sprintf will be called in all case to generate the returned // error - return log.ErrorStackDepth(2, fmt.Sprintf(format, params...)) + return pkglog.ErrorStackDepth(2, fmt.Sprintf(format, params...)) } // Critical implements Component#Critical. -func (*logger) Critical(v ...interface{}) error { return log.CriticalStackDepth(2, v...) } +func (*logger) Critical(v ...interface{}) error { return pkglog.CriticalStackDepth(2, v...) } // Criticalf implements Component#Criticalf. func (*logger) Criticalf(format string, params ...interface{}) error { // no need to check the current log level since Sprintf will be called in all case to generate the returned // error - return log.CriticalStackDepth(2, fmt.Sprintf(format, params...)) + return pkglog.CriticalStackDepth(2, fmt.Sprintf(format, params...)) } // Flush implements Component#Flush. func (*logger) Flush() { - log.Flush() + pkglog.Flush() } diff --git a/comp/core/log/logger_test.go b/comp/core/log/logimpl/logger_test.go similarity index 82% rename from comp/core/log/logger_test.go rename to comp/core/log/logimpl/logger_test.go index 625387b685e55..614e0faa441d1 100644 --- a/comp/core/log/logger_test.go +++ b/comp/core/log/logimpl/logger_test.go @@ -3,7 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -package log +package logimpl import ( "testing" @@ -11,11 +11,12 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log" "github.com/DataDog/datadog-agent/pkg/util/fxutil" ) func TestLogging(t *testing.T) { - log := fxutil.Test[Component](t, fx.Options( + log := fxutil.Test[log.Component](t, fx.Options( fx.Supply(ForOneShot("TEST", "debug", false)), config.MockModule, Module, diff --git a/comp/core/log/mock.go b/comp/core/log/logimpl/mock.go similarity index 70% rename from comp/core/log/mock.go rename to comp/core/log/logimpl/mock.go index 75fb96c56d2ab..7e2215e14514c 100644 --- a/comp/core/log/mock.go +++ b/comp/core/log/logimpl/mock.go @@ -3,7 +3,9 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -package log +//go:build test + +package logimpl import ( "context" @@ -13,10 +15,22 @@ import ( "testing" "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log" "github.com/cihub/seelog" "go.uber.org/fx" - "github.com/DataDog/datadog-agent/pkg/util/log" + "github.com/DataDog/datadog-agent/pkg/util/fxutil" + pkglog "github.com/DataDog/datadog-agent/pkg/util/log" +) + +// MockModule defines the fx options for the mock component. +var MockModule fx.Option = fxutil.Component( + fx.Provide(newMockLogger), +) + +// TraceMockModule defines the fx options for the mock component in its Trace variant. +var TraceMockModule fx.Option = fxutil.Component( + fx.Provide(newTraceMockLogger), ) // tbWriter is an implementation of io.Writer that sends lines to @@ -33,7 +47,7 @@ func (tbw *tbWriter) Write(p []byte) (n int, err error) { return len(p), nil } -func newMockLogger(t testing.TB, lc fx.Lifecycle) (Component, error) { +func newMockLogger(t testing.TB, lc fx.Lifecycle) (log.Component, error) { // Build a logger that only logs to t.Log(..) iface, err := seelog.LoggerFromWriterWithMinLevelAndFormat(&tbWriter{t}, seelog.TraceLvl, "%Date(2006-01-02 15:04:05 MST) | %LEVEL | (%ShortFilePath:%Line in %FuncShort) | %ExtraTextContext%Msg%n") @@ -48,12 +62,12 @@ func newMockLogger(t testing.TB, lc fx.Lifecycle) (Component, error) { }}) // install the logger into pkg/util/log - log.ChangeLogLevel(iface, "off") + pkglog.ChangeLogLevel(iface, "off") return &logger{}, nil } -func newTraceMockLogger(t testing.TB, lc fx.Lifecycle, params Params, cfg config.Component) (Component, error) { +func newTraceMockLogger(t testing.TB, lc fx.Lifecycle, params Params, cfg config.Component) (log.Component, error) { // Make sure we are setting a default value on purpose. logFilePath := params.logFileFn(cfg) if logFilePath != os.Getenv("DDTEST_DEFAULT_LOG_FILE_PATH") { diff --git a/comp/core/log/mock_test.go b/comp/core/log/logimpl/mock_test.go similarity index 82% rename from comp/core/log/mock_test.go rename to comp/core/log/logimpl/mock_test.go index a209d26549962..cbaaf9072c8a1 100644 --- a/comp/core/log/mock_test.go +++ b/comp/core/log/logimpl/mock_test.go @@ -3,7 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -package log +package logimpl import ( "testing" @@ -11,11 +11,12 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log" "github.com/DataDog/datadog-agent/pkg/util/fxutil" ) func TestMockLogging(t *testing.T) { - log := fxutil.Test[Component](t, fx.Options( + log := fxutil.Test[log.Component](t, fx.Options( fx.Supply(Params{}), config.MockModule, MockModule, diff --git a/comp/core/log/params.go b/comp/core/log/logimpl/params.go similarity index 99% rename from comp/core/log/params.go rename to comp/core/log/logimpl/params.go index 7cdb3dede50e3..9ad899794fdda 100644 --- a/comp/core/log/params.go +++ b/comp/core/log/logimpl/params.go @@ -3,7 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -package log +package logimpl import ( "runtime" diff --git a/comp/core/log/params_test.go b/comp/core/log/logimpl/params_test.go similarity index 99% rename from comp/core/log/params_test.go rename to comp/core/log/logimpl/params_test.go index d93a5014e9801..94327274d0497 100644 --- a/comp/core/log/params_test.go +++ b/comp/core/log/logimpl/params_test.go @@ -3,7 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -package log +package logimpl import ( "runtime" diff --git a/comp/core/log/trace_logger.go b/comp/core/log/logimpl/trace_logger.go similarity index 67% rename from comp/core/log/trace_logger.go rename to comp/core/log/logimpl/trace_logger.go index 941a6f245f74d..932279fbead16 100644 --- a/comp/core/log/trace_logger.go +++ b/comp/core/log/logimpl/trace_logger.go @@ -3,7 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -package log +package logimpl import ( "context" @@ -13,10 +13,11 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log" pkgconfiglogs "github.com/DataDog/datadog-agent/pkg/config/logs" tracelog "github.com/DataDog/datadog-agent/pkg/trace/log" "github.com/DataDog/datadog-agent/pkg/trace/telemetry" - "github.com/DataDog/datadog-agent/pkg/util/log" + pkglog "github.com/DataDog/datadog-agent/pkg/util/log" ) const stackDepth = 3 @@ -33,62 +34,64 @@ type tracelogger struct { // We check the current log level to avoid calling Sprintf when it's not needed (Sprintf from Tracef uses a lot a CPU) // Trace implements Component#Trace. -func (*tracelogger) Trace(v ...interface{}) { log.TraceStackDepth(stackDepth, v...) } +func (*tracelogger) Trace(v ...interface{}) { pkglog.TraceStackDepth(stackDepth, v...) } // Tracef implements Component#Tracef. func (*tracelogger) Tracef(format string, params ...interface{}) { - log.TracefStackDepth(stackDepth, format, params...) + pkglog.TracefStackDepth(stackDepth, format, params...) } // Debug implements Component#Debug. -func (*tracelogger) Debug(v ...interface{}) { log.DebugStackDepth(stackDepth, v...) } +func (*tracelogger) Debug(v ...interface{}) { pkglog.DebugStackDepth(stackDepth, v...) } // Debugf implements Component#Debugf. func (*tracelogger) Debugf(format string, params ...interface{}) { - log.DebugfStackDepth(stackDepth, format, params...) + pkglog.DebugfStackDepth(stackDepth, format, params...) } // Info implements Component#Info. -func (*tracelogger) Info(v ...interface{}) { log.InfoStackDepth(stackDepth, v...) } +func (*tracelogger) Info(v ...interface{}) { pkglog.InfoStackDepth(stackDepth, v...) } // Infof implements Component#Infof. func (*tracelogger) Infof(format string, params ...interface{}) { - log.InfofStackDepth(stackDepth, format, params...) + pkglog.InfofStackDepth(stackDepth, format, params...) } // Warn implements Component#Warn. -func (*tracelogger) Warn(v ...interface{}) error { return log.WarnStackDepth(stackDepth, v...) } +func (*tracelogger) Warn(v ...interface{}) error { return pkglog.WarnStackDepth(stackDepth, v...) } // Warnf implements Component#Warnf. func (*tracelogger) Warnf(format string, params ...interface{}) error { - return log.WarnfStackDepth(stackDepth, format, params...) + return pkglog.WarnfStackDepth(stackDepth, format, params...) } // Error implements Component#Error. -func (*tracelogger) Error(v ...interface{}) error { return log.ErrorStackDepth(stackDepth, v...) } +func (*tracelogger) Error(v ...interface{}) error { return pkglog.ErrorStackDepth(stackDepth, v...) } // Errorf implements Component#Errorf. func (*tracelogger) Errorf(format string, params ...interface{}) error { - return log.ErrorfStackDepth(stackDepth, format, params...) + return pkglog.ErrorfStackDepth(stackDepth, format, params...) } // Critical implements Component#Critical. -func (*tracelogger) Critical(v ...interface{}) error { return log.CriticalStackDepth(stackDepth, v...) } +func (*tracelogger) Critical(v ...interface{}) error { + return pkglog.CriticalStackDepth(stackDepth, v...) +} // Criticalf implements Component#Criticalf. func (*tracelogger) Criticalf(format string, params ...interface{}) error { - return log.CriticalfStackDepth(stackDepth, format, params...) + return pkglog.CriticalfStackDepth(stackDepth, format, params...) } // Flush implements Component#Flush. -func (*tracelogger) Flush() { log.Flush() } +func (*tracelogger) Flush() { pkglog.Flush() } -func newTraceLogger(lc fx.Lifecycle, params Params, config config.Component, telemetryCollector telemetry.TelemetryCollector) (Component, error) { +func newTraceLogger(lc fx.Lifecycle, params Params, config config.Component, telemetryCollector telemetry.TelemetryCollector) (log.Component, error) { return NewTraceLogger(lc, params, config, telemetryCollector) } -// NewTraceLogger creates a log.Component using the provided config.LogConfig -func NewTraceLogger(lc fx.Lifecycle, params Params, config config.LogConfig, telemetryCollector telemetry.TelemetryCollector) (Component, error) { +// NewTraceLogger creates a pkglog.Component using the provided config.LogConfig +func NewTraceLogger(lc fx.Lifecycle, params Params, config config.LogConfig, telemetryCollector telemetry.TelemetryCollector) (log.Component, error) { if params.logLevelFn == nil { return nil, errors.New("must call one of core.BundleParams.ForOneShot or ForDaemon") } diff --git a/tasks/components.py b/tasks/components.py index 5a25f9171a4d3..8126ed91bc426 100644 --- a/tasks/components.py +++ b/tasks/components.py @@ -52,7 +52,6 @@ def check_component(file, content): "comp/aggregator/demultiplexer/component.go", "comp/core/config/component.go", "comp/core/flare/component.go", - "comp/core/log/component.go", "comp/core/telemetry/component.go", "comp/dogstatsd/replay/component.go", "comp/dogstatsd/server/component.go", From 0bc6f9249045992d51ae879ece5e2b9b682ff2c1 Mon Sep 17 00:00:00 2001 From: Olivier G Date: Wed, 29 Nov 2023 15:17:18 +0100 Subject: [PATCH 2/7] Rename log to logimpl except for Component. --- comp/core/bundle.go | 6 +-- comp/core/bundle_mock.go | 6 +-- comp/core/bundle_params.go | 6 +-- comp/core/log/logimpl/params.go | 2 +- comp/core/workloadmeta/dump_test.go | 4 +- comp/core/workloadmeta/store_example_test.go | 4 +- comp/core/workloadmeta/store_test.go | 30 +++++++-------- comp/dogstatsd/server/server.go | 3 +- comp/dogstatsd/server/server_test.go | 13 ++++--- .../serverDebug/serverdebugimpl/debug.go | 3 +- .../blocked_endpoints_test.go | 31 ++++++++-------- .../defaultforwarder/domain_forwarder_test.go | 27 +++++++------- .../defaultforwarder/forwarder_health_test.go | 7 ++-- .../defaultforwarder/forwarder_test.go | 37 ++++++++++--------- .../http_transactions_serializer_test.go | 7 ++-- .../retry/on_disk_retry_queue_test.go | 3 +- .../retry/transaction_retry_queue_test.go | 3 +- .../transaction/transaction_test.go | 11 +++--- .../forwarder/defaultforwarder/worker_test.go | 15 ++++---- comp/languagedetection/bundle_test.go | 6 +-- comp/languagedetection/client/client_test.go | 6 +-- comp/logs/agent/serverless.go | 2 +- comp/metadata/host/host_test.go | 8 ++-- .../internal/util/inventory_payload_test.go | 3 +- .../inventoryagent/inventoryagent_test.go | 4 +- .../inventoryhostimpl/inventoryhost_test.go | 4 +- .../resources/resourcesimpl/resources_test.go | 9 ++--- .../metadata/runner/runnerimpl/runner_test.go | 6 +-- comp/netflow/config/config_test.go | 8 ++-- .../netflow/flowaggregator/aggregator_test.go | 23 ++++++------ .../flowaggregator/flowaccumulator_test.go | 7 ++-- comp/netflow/goflowlib/flowstate_test.go | 6 ++- comp/netflow/server/server_test.go | 4 +- comp/process/bundle_test.go | 4 +- comp/remote-config/rcclient/rcclient_test.go | 4 +- comp/trace/bundle_test.go | 8 ++-- pkg/aggregator/aggregator_test.go | 14 +++---- pkg/aggregator/check_sampler_bench_test.go | 3 +- pkg/aggregator/demultiplexer_agent_test.go | 7 ++-- pkg/aggregator/demultiplexer_serverless.go | 3 +- pkg/aggregator/demultiplexer_test.go | 9 +++-- pkg/aggregator/mocksender/mocksender.go | 4 +- pkg/aggregator/sender_test.go | 13 ++++--- pkg/autodiscovery/providers/container_test.go | 6 +-- pkg/cli/subcommands/check/command.go | 4 +- pkg/cli/subcommands/clusterchecks/command.go | 3 +- pkg/cli/subcommands/config/command.go | 3 +- pkg/cli/subcommands/dcaconfigcheck/command.go | 3 +- pkg/cli/subcommands/dcaflare/command.go | 4 +- pkg/cli/subcommands/health/command.go | 3 +- pkg/cli/subcommands/taggerlist/command.go | 3 +- pkg/cli/subcommands/workloadlist/command.go | 3 +- .../mutate/auto_instrumentation_util_test.go | 4 +- pkg/collector/collector_demux_test.go | 3 +- .../kubelet/provider/summary/provider_test.go | 4 +- .../corechecks/sbom/processor_test.go | 3 +- pkg/collector/corechecks/snmp/snmp_test.go | 3 +- .../container/tailerfactory/file_test.go | 5 +-- pkg/metadata/scheduler_test.go | 4 +- pkg/process/runner/submitter_test.go | 3 +- .../invocationlifecycle/lifecycle_test.go | 25 +++++++------ pkg/serverless/logs/logs_test.go | 29 ++++++++------- .../metrics/enhanced_metrics_test.go | 25 +++++++------ pkg/snmp/traps/config/config_test.go | 5 ++- pkg/snmp/traps/formatter/formatter_test.go | 19 +++++----- pkg/snmp/traps/forwarder/forwarder_test.go | 3 +- pkg/snmp/traps/listener/listener_test.go | 3 +- .../traps/oid_resolver/oid_resolver_test.go | 15 ++++---- pkg/snmp/traps/server_test.go | 3 +- pkg/tagger/collectors/workloadmeta_test.go | 10 ++--- .../containerd/collector_linux_test.go | 5 +-- .../containerd/collector_windows_test.go | 5 +-- .../metrics/docker/collector_test.go | 3 +- pkg/util/trivy/cache_test.go | 3 +- .../corechecks/docker/main_test.go | 2 +- 75 files changed, 317 insertions(+), 282 deletions(-) diff --git a/comp/core/bundle.go b/comp/core/bundle.go index b10b303fdd141..62ee6eac21177 100644 --- a/comp/core/bundle.go +++ b/comp/core/bundle.go @@ -17,7 +17,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/hostname/hostnameimpl" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/secrets/secretsimpl" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" @@ -32,8 +32,8 @@ var Bundle = fxutil.Bundle( // As `config.Module` expects `config.Params` as a parameter, it is require to define how to get `config.Params` from `BundleParams`. fx.Provide(func(params BundleParams) config.Params { return params.ConfigParams }), config.Module, - fx.Provide(func(params BundleParams) log.Params { return params.LogParams }), - log.Module, + fx.Provide(func(params BundleParams) logimpl.Params { return params.LogParams }), + logimpl.Module, fx.Provide(func(params BundleParams) sysprobeconfigimpl.Params { return params.SysprobeConfigParams }), secretsimpl.Module, fx.Provide(func(params BundleParams) secrets.Params { return params.SecretParams }), diff --git a/comp/core/bundle_mock.go b/comp/core/bundle_mock.go index 80f31d3beaab7..8dcb38acd2499 100644 --- a/comp/core/bundle_mock.go +++ b/comp/core/bundle_mock.go @@ -18,7 +18,7 @@ package core import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/hostname/hostnameimpl" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" "github.com/DataDog/datadog-agent/comp/core/telemetry" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -43,6 +43,6 @@ func MakeMockBundle(logParams, logger fx.Option) fxutil.BundleOptions { // MockBundle defines the mock fx options for this bundle. var MockBundle = MakeMockBundle( - fx.Supply(log.Params{}), - log.MockModule, + fx.Supply(logimpl.Params{}), + logimpl.MockModule, ) diff --git a/comp/core/bundle_params.go b/comp/core/bundle_params.go index 701cdad9afba6..57515af7f19de 100644 --- a/comp/core/bundle_params.go +++ b/comp/core/bundle_params.go @@ -7,7 +7,7 @@ package core import ( "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" ) @@ -16,7 +16,7 @@ import ( // // Logs-related parameters are implemented as unexported fields containing // callbacks. These fields can be set with the `LogXxx()` methods, which -// return the updated BundleParams. One of `log.ForOneShot` or `log.ForDaemon` +// return the updated BundleParams. One of `logimpl.ForOneShot` or `logimpl.ForDaemon` // must be called. type BundleParams struct { ConfigParams @@ -32,7 +32,7 @@ type ConfigParams = config.Params type SecretParams = secrets.Params // LogParams defines the parameters of the log component -type LogParams = log.Params +type LogParams = logimpl.Params // SysprobeConfigParams defines the parameters of the system-probe config component type SysprobeConfigParams = sysprobeconfigimpl.Params diff --git a/comp/core/log/logimpl/params.go b/comp/core/log/logimpl/params.go index 9ad899794fdda..fadbe4a76f45d 100644 --- a/comp/core/log/logimpl/params.go +++ b/comp/core/log/logimpl/params.go @@ -15,7 +15,7 @@ import ( // // Logs-related parameters are implemented as unexported fields containing // callbacks. These fields can be set with the `LogXxx()` methods, which -// return the updated LogParams. One of `log.ForOneShot` or `log.ForDaemon` +// return the updated LogParams. One of `logimpl.ForOneShot` or `logimpl.ForDaemon` // must be called. type Params struct { // loggerName is the name that appears in the logfile diff --git a/comp/core/workloadmeta/dump_test.go b/comp/core/workloadmeta/dump_test.go index 801c7e2170ad8..f45774b472621 100644 --- a/comp/core/workloadmeta/dump_test.go +++ b/comp/core/workloadmeta/dump_test.go @@ -10,7 +10,7 @@ import ( "testing" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/util/fxutil" "github.com/stretchr/testify/assert" "go.uber.org/fx" @@ -19,7 +19,7 @@ import ( func TestDump(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(context.Background()), fx.Supply(NewParams()), diff --git a/comp/core/workloadmeta/store_example_test.go b/comp/core/workloadmeta/store_example_test.go index 810265e4524c6..b260288143e09 100644 --- a/comp/core/workloadmeta/store_example_test.go +++ b/comp/core/workloadmeta/store_example_test.go @@ -10,7 +10,7 @@ import ( "testing" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/util/fxutil" "go.uber.org/fx" ) @@ -18,7 +18,7 @@ import ( func TestExampleStoreSubscribe(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) diff --git a/comp/core/workloadmeta/store_test.go b/comp/core/workloadmeta/store_test.go index 14e3eba272cbd..abcc8835991b5 100644 --- a/comp/core/workloadmeta/store_test.go +++ b/comp/core/workloadmeta/store_test.go @@ -14,7 +14,7 @@ import ( "gotest.tools/assert" //nolint:depguard "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/errors" "github.com/DataDog/datadog-agent/pkg/languagedetection/languagemodels" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -29,7 +29,7 @@ const ( func TestHandleEvents(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -590,7 +590,7 @@ func TestSubscribe(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -632,7 +632,7 @@ func TestSubscribe(t *testing.T) { func TestGetKubernetesDeployment(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -675,7 +675,7 @@ func TestGetKubernetesDeployment(t *testing.T) { func TestGetProcess(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -754,7 +754,7 @@ func TestListContainers(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -792,7 +792,7 @@ func TestListContainersWithFilter(t *testing.T) { } deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -851,7 +851,7 @@ func TestListProcesses(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -889,7 +889,7 @@ func TestListProcessesWithFilter(t *testing.T) { } deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -1006,7 +1006,7 @@ func TestGetKubernetesPodByName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -1067,7 +1067,7 @@ func TestListImages(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -1119,7 +1119,7 @@ func TestGetImage(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -1214,7 +1214,7 @@ func TestResetProcesses(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -1412,7 +1412,7 @@ func TestReset(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) @@ -1459,7 +1459,7 @@ func TestNoDataRace(t *testing.T) { //nolint:revive // TODO fix revive unused-pa // This test ensures that no race conditions are encountered when the "--race" flag is passed // to the test process and an entity is accessed in a different thread than the one handling events deps := fxutil.Test[dependencies](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewParams()), )) diff --git a/comp/dogstatsd/server/server.go b/comp/dogstatsd/server/server.go index 65d10ccac4744..c7f22e0f955f0 100644 --- a/comp/dogstatsd/server/server.go +++ b/comp/dogstatsd/server/server.go @@ -19,6 +19,7 @@ import ( configComponent "github.com/DataDog/datadog-agent/comp/core/config" logComponent "github.com/DataDog/datadog-agent/comp/core/log" + logComponentImpl "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/dogstatsd/listeners" "github.com/DataDog/datadog-agent/comp/dogstatsd/mapper" "github.com/DataDog/datadog-agent/comp/dogstatsd/packets" @@ -188,7 +189,7 @@ func initTelemetry(cfg config.Reader, logger logComponent.Component) { // TODO: (components) - remove once serverless is an FX app func NewServerlessServer() Component { - return newServerCompat(config.Datadog, logComponent.NewTemporaryLoggerWithoutInit(), replay.NewServerlessTrafficCapture(), serverdebugimpl.NewServerlessServerDebug(), true) + return newServerCompat(config.Datadog, logComponentImpl.NewTemporaryLoggerWithoutInit(), replay.NewServerlessTrafficCapture(), serverdebugimpl.NewServerlessServerDebug(), true) } // TODO: (components) - merge with newServerCompat once NewServerlessServer is removed diff --git a/comp/dogstatsd/server/server_test.go b/comp/dogstatsd/server/server_test.go index 955ac623696f9..1c9709dd6b66a 100644 --- a/comp/dogstatsd/server/server_test.go +++ b/comp/dogstatsd/server/server_test.go @@ -22,6 +22,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" configComponent "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/dogstatsd/listeners" "github.com/DataDog/datadog-agent/comp/dogstatsd/replay" "github.com/DataDog/datadog-agent/comp/dogstatsd/serverDebug/serverdebugimpl" @@ -82,7 +83,7 @@ func TestNewServer(t *testing.T) { deps := fulfillDepsWithConfigOverride(t, cfg) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, 10*time.Millisecond) defer demux.Stop(false) requireStart(t, deps.Server, demux) @@ -97,7 +98,7 @@ func TestStopServer(t *testing.T) { deps := fulfillDepsWithConfigOverride(t, cfg) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, 10*time.Millisecond) defer demux.Stop(false) requireStart(t, deps.Server, demux) @@ -471,7 +472,7 @@ func TestHistToDist(t *testing.T) { deps := fulfillDepsWithConfigOverride(t, cfg) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, 10*time.Millisecond) defer demux.Stop(false) requireStart(t, deps.Server, demux) @@ -559,7 +560,7 @@ func TestE2EParsing(t *testing.T) { cfg["dogstatsd_port"] = listeners.RandomPortName deps := fulfillDepsWithConfigOverride(t, cfg) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, 10*time.Millisecond) requireStart(t, deps.Server, demux) @@ -604,7 +605,7 @@ func TestExtraTags(t *testing.T) { deps := fulfillDepsWithConfigOverrideAndFeatures(t, cfg, []config.Feature{config.EKSFargate}) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, 10*time.Millisecond) requireStart(t, deps.Server, demux) defer deps.Server.Stop() @@ -634,7 +635,7 @@ func TestStaticTags(t *testing.T) { deps := fulfillDepsWithConfigOverrideAndFeatures(t, cfg, []config.Feature{config.EKSFargate}) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, 10*time.Millisecond) requireStart(t, deps.Server, demux) defer deps.Server.Stop() diff --git a/comp/dogstatsd/serverDebug/serverdebugimpl/debug.go b/comp/dogstatsd/serverDebug/serverdebugimpl/debug.go index 699f91d494c5a..5966498168d48 100644 --- a/comp/dogstatsd/serverDebug/serverdebugimpl/debug.go +++ b/comp/dogstatsd/serverDebug/serverdebugimpl/debug.go @@ -23,6 +23,7 @@ import ( commonpath "github.com/DataDog/datadog-agent/cmd/agent/common/path" configComponent "github.com/DataDog/datadog-agent/comp/core/config" logComponent "github.com/DataDog/datadog-agent/comp/core/log" + logComponentImpl "github.com/DataDog/datadog-agent/comp/core/log/logimpl" serverdebug "github.com/DataDog/datadog-agent/comp/dogstatsd/serverDebug" "github.com/DataDog/datadog-agent/pkg/aggregator/ckey" "github.com/DataDog/datadog-agent/pkg/config" @@ -72,7 +73,7 @@ type serverDebugImpl struct { // NewServerlessServerDebug creates a new instance of serverDebug.Component func NewServerlessServerDebug() serverdebug.Component { - return newServerDebugCompat(logComponent.NewTemporaryLoggerWithoutInit(), config.Datadog) + return newServerDebugCompat(logComponentImpl.NewTemporaryLoggerWithoutInit(), config.Datadog) } // newServerDebug creates a new instance of a ServerDebug diff --git a/comp/forwarder/defaultforwarder/blocked_endpoints_test.go b/comp/forwarder/defaultforwarder/blocked_endpoints_test.go index 3ae05b2303adc..f61f52ff43931 100644 --- a/comp/forwarder/defaultforwarder/blocked_endpoints_test.go +++ b/comp/forwarder/defaultforwarder/blocked_endpoints_test.go @@ -15,6 +15,7 @@ import ( "github.com/stretchr/testify/require" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/config" "github.com/DataDog/datadog-agent/pkg/util/backoff" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -26,7 +27,7 @@ func init() { func TestMinBackoffFactorValid(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) policy, ok := e.backoffPolicy.(*backoff.ExpBackoffPolicy) @@ -52,7 +53,7 @@ func TestMinBackoffFactorValid(t *testing.T) { func TestBaseBackoffTimeValid(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) policy, ok := e.backoffPolicy.(*backoff.ExpBackoffPolicy) @@ -79,7 +80,7 @@ func TestBaseBackoffTimeValid(t *testing.T) { func TestMaxBackoffTimeValid(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) policy, ok := e.backoffPolicy.(*backoff.ExpBackoffPolicy) @@ -106,7 +107,7 @@ func TestMaxBackoffTimeValid(t *testing.T) { func TestRecoveryIntervalValid(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) policy, ok := e.backoffPolicy.(*backoff.ExpBackoffPolicy) @@ -143,7 +144,7 @@ func TestRecoveryIntervalValid(t *testing.T) { // Test we increase delay on average func TestGetBackoffDurationIncrease(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) previousBackoffDuration := time.Duration(0) * time.Second backoffIncrease := 0 @@ -171,7 +172,7 @@ func TestGetBackoffDurationIncrease(t *testing.T) { func TestMaxGetBackoffDuration(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) backoffDuration := e.getBackoffDuration(100) @@ -183,7 +184,7 @@ func TestMaxGetBackoffDuration(t *testing.T) { func TestMaxErrors(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) previousBackoffDuration := time.Duration(0) * time.Second attempts := 0 @@ -209,7 +210,7 @@ func TestMaxErrors(t *testing.T) { func TestBlock(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) e.close("test") @@ -221,7 +222,7 @@ func TestBlock(t *testing.T) { func TestMaxBlock(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) e.close("test") e.errorPerEndpoint["test"].nbError = 1000000 @@ -242,7 +243,7 @@ func TestMaxBlock(t *testing.T) { func TestUnblock(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) e.close("test") @@ -262,7 +263,7 @@ func TestUnblock(t *testing.T) { func TestMaxUnblock(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) e.close("test") @@ -277,7 +278,7 @@ func TestMaxUnblock(t *testing.T) { func TestUnblockUnknown(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) e.recover("test") @@ -287,7 +288,7 @@ func TestUnblockUnknown(t *testing.T) { func TestIsBlock(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) assert.False(t, e.isBlock("test")) @@ -301,7 +302,7 @@ func TestIsBlock(t *testing.T) { func TestIsBlockTiming(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) // setting an old close @@ -315,7 +316,7 @@ func TestIsBlockTiming(t *testing.T) { func TestIsblockUnknown(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) e := newBlockedEndpoints(mockConfig, log) assert.False(t, e.isBlock("test")) diff --git a/comp/forwarder/defaultforwarder/domain_forwarder_test.go b/comp/forwarder/defaultforwarder/domain_forwarder_test.go index 86765e2644345..90e6d11cc1538 100644 --- a/comp/forwarder/defaultforwarder/domain_forwarder_test.go +++ b/comp/forwarder/defaultforwarder/domain_forwarder_test.go @@ -17,6 +17,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder/internal/retry" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder/transaction" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -25,7 +26,7 @@ import ( func TestNewDomainForwarder(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 120*time.Second) assert.NotNil(t, forwarder) @@ -44,7 +45,7 @@ func TestNewDomainForwarder(t *testing.T) { func TestDomainForwarderStart(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 0) err := forwarder.Start() @@ -65,7 +66,7 @@ func TestDomainForwarderStart(t *testing.T) { func TestDomainForwarderInit(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 0) forwarder.init() assert.Len(t, forwarder.workers, 0) @@ -74,7 +75,7 @@ func TestDomainForwarderInit(t *testing.T) { func TestDomainForwarderStop(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 0) forwarder.Stop(false) // this should be a noop forwarder.Start() @@ -87,7 +88,7 @@ func TestDomainForwarderStop(t *testing.T) { func TestDomainForwarderStop_WithConnectionReset(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 120*time.Second) forwarder.Stop(false) // this should be a noop forwarder.Start() @@ -100,7 +101,7 @@ func TestDomainForwarderStop_WithConnectionReset(t *testing.T) { func TestDomainForwarderSendHTTPTransactions(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 0) tr := newTestTransactionDomainForwarder() @@ -122,7 +123,7 @@ func TestDomainForwarderSendHTTPTransactions(t *testing.T) { func TestRequeueTransaction(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 0) tr := transaction.NewHTTPTransaction() requireLenForwarderRetryQueue(t, forwarder, 0) @@ -132,7 +133,7 @@ func TestRequeueTransaction(t *testing.T) { func TestRetryTransactions(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 0) forwarder.init() @@ -167,7 +168,7 @@ func TestRetryTransactions(t *testing.T) { func TestForwarderRetry(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 0) forwarder.Start() defer forwarder.Stop(false) @@ -203,7 +204,7 @@ func TestForwarderRetry(t *testing.T) { func TestForwarderRetryLifo(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 0) forwarder.init() @@ -234,7 +235,7 @@ func TestForwarderRetryLifo(t *testing.T) { func TestForwarderRetryLimitQueue(t *testing.T) { mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 0) forwarder.init() forwarder.blockedList.close("blocked") @@ -280,7 +281,7 @@ func TestDomainForwarderRetryQueueAllPayloadsMaxSize(t *testing.T) { telemetry, retry.NewPointCountTelemetryMock()) mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarder(mockConfig, log, "test", transactionRetryQueue, 0, 10, transaction.SortByCreatedTimeAndPriority{HighPriorityFirst: true}, retry.NewPointCountTelemetry("domain", nil)) forwarder.blockedList.close("blocked") forwarder.blockedList.errorPerEndpoint["blocked"].until = time.Now().Add(1 * time.Minute) @@ -308,7 +309,7 @@ func TestDomainForwarderRetryQueueAllPayloadsMaxSize(t *testing.T) { func TestDomainForwarderInitConfigs(t *testing.T) { // Test default values mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := newDomainForwarderForTest(mockConfig, log, 0) forwarder.init() assert.Equal(t, 100, cap(forwarder.highPrio)) diff --git a/comp/forwarder/defaultforwarder/forwarder_health_test.go b/comp/forwarder/defaultforwarder/forwarder_health_test.go index 13f771c240f7b..f310c597852f9 100644 --- a/comp/forwarder/defaultforwarder/forwarder_health_test.go +++ b/comp/forwarder/defaultforwarder/forwarder_health_test.go @@ -16,6 +16,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/config/resolver" "github.com/DataDog/datadog-agent/pkg/util/fxutil" ) @@ -34,7 +35,7 @@ func TestHasValidAPIKey(t *testing.T) { ts1.URL: {"api_key1", "api_key2"}, ts2.URL: {"key3"}, } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) cfg := fxutil.Test[config.Component](t, config.MockModule) fh := forwarderHealth{log: log, config: cfg, domainResolvers: resolver.NewSingleDomainResolvers(keysPerDomains)} fh.init() @@ -75,7 +76,7 @@ func TestComputeDomainsURL(t *testing.T) { for _, keys := range expectedMap { sort.Strings(keys) } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) fh := forwarderHealth{log: log, domainResolvers: resolver.NewSingleDomainResolvers(keysPerDomains)} fh.init() @@ -115,7 +116,7 @@ func TestHasValidAPIKeyErrors(t *testing.T) { ts2.URL: {"key3"}, ts3.URL: {"key4"}, } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) cfg := fxutil.Test[config.Component](t, config.MockModule) fh := forwarderHealth{log: log, config: cfg} fh.init() diff --git a/comp/forwarder/defaultforwarder/forwarder_test.go b/comp/forwarder/defaultforwarder/forwarder_test.go index b469f5de25a49..e51634665a001 100644 --- a/comp/forwarder/defaultforwarder/forwarder_test.go +++ b/comp/forwarder/defaultforwarder/forwarder_test.go @@ -19,6 +19,7 @@ import ( "go.uber.org/atomic" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder/endpoints" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder/transaction" "github.com/DataDog/datadog-agent/pkg/config" @@ -49,7 +50,7 @@ var ( func TestNewDefaultForwarder(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(keysPerDomains))) assert.NotNil(t, forwarder) @@ -81,7 +82,7 @@ func TestFeature(t *testing.T) { func TestStart(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(monoKeysDomains))) err := forwarder.Start() defer forwarder.Stop() @@ -111,7 +112,7 @@ func TestStopWithPurgingTransaction(t *testing.T) { func testStop(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(keysPerDomains))) assert.Equal(t, Stopped, forwarder.State()) forwarder.Stop() // this should be a noop @@ -128,7 +129,7 @@ func testStop(t *testing.T) { func TestSubmitIfStopped(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(monoKeysDomains))) require.NotNil(t, forwarder) @@ -144,7 +145,7 @@ func TestSubmitIfStopped(t *testing.T) { func TestCreateHTTPTransactions(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(keysPerDomains))) endpoint := transaction.Endpoint{Route: "/api/foo", Name: "foo"} p1 := []byte("A payload") @@ -177,7 +178,7 @@ func TestCreateHTTPTransactions(t *testing.T) { func TestCreateHTTPTransactionsWithMultipleDomains(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(keysWithMultipleDomains))) endpoint := transaction.Endpoint{Route: "/api/foo", Name: "foo"} p1 := []byte("A payload") @@ -218,7 +219,7 @@ func TestCreateHTTPTransactionsWithDifferentResolvers(t *testing.T) { additionalResolver.RegisterAlternateDestination("diversion.domain", "diverted_name", resolver.Vector) resolvers["datadog.vector"] = additionalResolver mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolvers)) endpoint := transaction.Endpoint{Route: "/api/foo", Name: "diverted_name"} p1 := []byte("A payload") @@ -262,7 +263,7 @@ func TestCreateHTTPTransactionsWithOverrides(t *testing.T) { r.RegisterAlternateDestination("observability_pipelines_worker.tld", "diverted", resolver.Vector) resolvers[testDomain] = r mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolvers)) endpoint := transaction.Endpoint{Route: "/api/foo", Name: "no_diverted"} @@ -289,7 +290,7 @@ func TestArbitraryTagsHTTPHeader(t *testing.T) { mockConfig := config.Mock(t) mockConfig.SetWithoutSource("allow_arbitrary_tags", true) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(keysPerDomains))) endpoint := transaction.Endpoint{Route: "/api/foo", Name: "foo"} payload := []byte("A payload") @@ -302,7 +303,7 @@ func TestArbitraryTagsHTTPHeader(t *testing.T) { func TestSendHTTPTransactions(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(keysPerDomains))) endpoint := transaction.Endpoint{Route: "/api/foo", Name: "foo"} p1 := []byte("A payload") @@ -322,7 +323,7 @@ func TestSendHTTPTransactions(t *testing.T) { func TestSubmitV1Intake(t *testing.T) { mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) forwarder := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(monoKeysDomains))) forwarder.Start() defer forwarder.Stop() @@ -365,7 +366,7 @@ func TestForwarderEndtoEnd(t *testing.T) { mockConfig := config.Mock(t) mockConfig.SetWithoutSource("dd_url", ts.URL) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) f := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(map[string][]string{ts.URL: {"api_key1", "api_key2"}, "invalid": {}, "invalid2": nil}))) f.Start() @@ -421,7 +422,7 @@ func TestTransactionEventHandlers(t *testing.T) { mockConfig := config.Mock(t) mockConfig.SetWithoutSource("dd_url", ts.URL) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) f := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(map[string][]string{ts.URL: {"api_key1"}}))) _ = f.Start() @@ -476,7 +477,7 @@ func TestTransactionEventHandlersOnRetry(t *testing.T) { mockConfig := config.Mock(t) mockConfig.SetWithoutSource("dd_url", ts.URL) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) f := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(map[string][]string{ts.URL: {"api_key1"}}))) _ = f.Start() @@ -527,7 +528,7 @@ func TestTransactionEventHandlersNotRetryable(t *testing.T) { mockConfig := config.Mock(t) mockConfig.SetWithoutSource("dd_url", ts.URL) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) f := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(map[string][]string{ts.URL: {"api_key1"}}))) _ = f.Start() @@ -581,7 +582,7 @@ func TestProcessLikePayloadResponseTimeout(t *testing.T) { defaultResponseTimeout = responseTimeout }() - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) f := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(map[string][]string{ts.URL: {"api_key1"}}))) _ = f.Start() @@ -633,7 +634,7 @@ func TestHighPriorityTransaction(t *testing.T) { defer func() { flushInterval = oldFlushInterval }() mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) f := NewDefaultForwarder(mockConfig, log, NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(map[string][]string{ts.URL: {"api_key1"}}))) f.Start() @@ -679,7 +680,7 @@ func TestCustomCompletionHandler(t *testing.T) { done <- struct{}{} } mockConfig := config.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) options := NewOptionsWithResolvers(mockConfig, log, resolver.NewSingleDomainResolvers(map[string][]string{ srv.URL: {"api_key1"}, })) diff --git a/comp/forwarder/defaultforwarder/internal/retry/http_transactions_serializer_test.go b/comp/forwarder/defaultforwarder/internal/retry/http_transactions_serializer_test.go index fdd9cc17550a5..4c79ad25e92bc 100644 --- a/comp/forwarder/defaultforwarder/internal/retry/http_transactions_serializer_test.go +++ b/comp/forwarder/defaultforwarder/internal/retry/http_transactions_serializer_test.go @@ -15,6 +15,7 @@ import ( "github.com/stretchr/testify/require" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder/transaction" "github.com/DataDog/datadog-agent/pkg/config/resolver" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -38,7 +39,7 @@ func TestHTTPSerializeDeserializeWithResolverOverride(t *testing.T) { func runTestHTTPSerializeDeserializeWithResolver(t *testing.T, d string, r resolver.DomainResolver) { a := assert.New(t) tr := createHTTPTransactionTests(d) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) serializer := NewHTTPTransactionsSerializer(log, r) a.NoError(serializer.Add(tr)) @@ -64,7 +65,7 @@ func runTestHTTPSerializeDeserializeWithResolver(t *testing.T, d string, r resol func TestPartialDeserialize(t *testing.T) { a := assert.New(t) initialTransaction := createHTTPTransactionTests(domain) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) serializer := NewHTTPTransactionsSerializer(log, resolver.NewSingleDomainResolver(domain, nil)) a.NoError(serializer.Add(initialTransaction)) @@ -86,7 +87,7 @@ func TestPartialDeserialize(t *testing.T) { func TestHTTPTransactionSerializerMissingAPIKey(t *testing.T) { r := require.New(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) serializer := NewHTTPTransactionsSerializer(log, resolver.NewSingleDomainResolver(domain, []string{apiKey1, apiKey2})) r.NoError(serializer.Add(createHTTPTransactionWithHeaderTests(http.Header{"Key": []string{apiKey1}}, domain))) diff --git a/comp/forwarder/defaultforwarder/internal/retry/on_disk_retry_queue_test.go b/comp/forwarder/defaultforwarder/internal/retry/on_disk_retry_queue_test.go index 8e2f80dc0cce9..8992aa19cfdc3 100644 --- a/comp/forwarder/defaultforwarder/internal/retry/on_disk_retry_queue_test.go +++ b/comp/forwarder/defaultforwarder/internal/retry/on_disk_retry_queue_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder/transaction" "github.com/DataDog/datadog-agent/pkg/config/resolver" "github.com/DataDog/datadog-agent/pkg/util/filesystem" @@ -134,7 +135,7 @@ func newTestOnDiskRetryQueue(t *testing.T, a *assert.Assertions, path string, ma Total: 10000, }} diskUsageLimit := NewDiskUsageLimit("", disk, maxSizeInBytes, 1) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) storage, err := newOnDiskRetryQueue(log, NewHTTPTransactionsSerializer(log, resolver.NewSingleDomainResolver(domainName, nil)), path, diskUsageLimit, telemetry, NewPointCountTelemetryMock()) a.NoError(err) return storage diff --git a/comp/forwarder/defaultforwarder/internal/retry/transaction_retry_queue_test.go b/comp/forwarder/defaultforwarder/internal/retry/transaction_retry_queue_test.go index 6055b9ded8053..09d91c37f02b3 100644 --- a/comp/forwarder/defaultforwarder/internal/retry/transaction_retry_queue_test.go +++ b/comp/forwarder/defaultforwarder/internal/retry/transaction_retry_queue_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder/transaction" "github.com/DataDog/datadog-agent/pkg/config/resolver" "github.com/DataDog/datadog-agent/pkg/util/filesystem" @@ -180,7 +181,7 @@ func newOnDiskRetryQueueTest(t *testing.T, a *assert.Assertions) *onDiskRetryQue Total: 10000, }} diskUsageLimit := NewDiskUsageLimit("", disk, 1000, 1) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) q, err := newOnDiskRetryQueue( log, NewHTTPTransactionsSerializer(log, resolver.NewSingleDomainResolver("", nil)), diff --git a/comp/forwarder/defaultforwarder/transaction/transaction_test.go b/comp/forwarder/defaultforwarder/transaction/transaction_test.go index 3fd32ca07efe7..10c6d7e2e87bb 100644 --- a/comp/forwarder/defaultforwarder/transaction/transaction_test.go +++ b/comp/forwarder/defaultforwarder/transaction/transaction_test.go @@ -15,6 +15,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" "github.com/DataDog/datadog-agent/pkg/util/fxutil" "github.com/stretchr/testify/assert" @@ -53,7 +54,7 @@ func TestProcess(t *testing.T) { client := &http.Client{} mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) err := transaction.Process(context.Background(), mockConfig, log, client) assert.Nil(t, err) } @@ -68,7 +69,7 @@ func TestProcessInvalidDomain(t *testing.T) { client := &http.Client{} mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) err := transaction.Process(context.Background(), mockConfig, log, client) assert.Nil(t, err) } @@ -83,7 +84,7 @@ func TestProcessNetworkError(t *testing.T) { client := &http.Client{} mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) err := transaction.Process(context.Background(), mockConfig, log, client) assert.NotNil(t, err) } @@ -105,7 +106,7 @@ func TestProcessHTTPError(t *testing.T) { client := &http.Client{} mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) err := transaction.Process(context.Background(), mockConfig, log, client) assert.NotNil(t, err) assert.Contains(t, err.Error(), "error \"503 Service Unavailable\" while sending transaction") @@ -137,7 +138,7 @@ func TestProcessCancel(t *testing.T) { cancel() mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) err := transaction.Process(ctx, mockConfig, log, client) assert.Nil(t, err) } diff --git a/comp/forwarder/defaultforwarder/worker_test.go b/comp/forwarder/defaultforwarder/worker_test.go index a10fb2ba25adb..90860570b02c3 100644 --- a/comp/forwarder/defaultforwarder/worker_test.go +++ b/comp/forwarder/defaultforwarder/worker_test.go @@ -17,6 +17,7 @@ import ( "go.uber.org/atomic" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder/transaction" "github.com/DataDog/datadog-agent/pkg/config" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -29,7 +30,7 @@ func TestNewWorker(t *testing.T) { requeue := make(chan transaction.Transaction) mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) w := NewWorker(mockConfig, log, highPrio, lowPrio, requeue, newBlockedEndpoints(mockConfig, log), &PointSuccessfullySentMock{}) assert.NotNil(t, w) assert.Equal(t, w.Client.Timeout, config.Datadog.GetDuration("forwarder_timeout")*time.Second) @@ -42,7 +43,7 @@ func TestNewNoSSLWorker(t *testing.T) { mockConfig := config.Mock(t) mockConfig.SetWithoutSource("skip_ssl_validation", true) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) w := NewWorker(mockConfig, log, highPrio, lowPrio, requeue, newBlockedEndpoints(mockConfig, log), &PointSuccessfullySentMock{}) assert.True(t, w.Client.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify) } @@ -53,7 +54,7 @@ func TestWorkerStart(t *testing.T) { requeue := make(chan transaction.Transaction, 1) sender := &PointSuccessfullySentMock{} mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) w := NewWorker(mockConfig, log, highPrio, lowPrio, requeue, newBlockedEndpoints(mockConfig, log), sender) mock := newTestTransaction() @@ -90,7 +91,7 @@ func TestWorkerRetry(t *testing.T) { lowPrio := make(chan transaction.Transaction) requeue := make(chan transaction.Transaction, 1) mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) w := NewWorker(mockConfig, log, highPrio, lowPrio, requeue, newBlockedEndpoints(mockConfig, log), &PointSuccessfullySentMock{}) mock := newTestTransaction() @@ -113,7 +114,7 @@ func TestWorkerRetryBlockedTransaction(t *testing.T) { lowPrio := make(chan transaction.Transaction) requeue := make(chan transaction.Transaction, 1) mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) w := NewWorker(mockConfig, log, highPrio, lowPrio, requeue, newBlockedEndpoints(mockConfig, log), &PointSuccessfullySentMock{}) mock := newTestTransaction() @@ -136,7 +137,7 @@ func TestWorkerResetConnections(t *testing.T) { lowPrio := make(chan transaction.Transaction) requeue := make(chan transaction.Transaction, 1) mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) w := NewWorker(mockConfig, log, highPrio, lowPrio, requeue, newBlockedEndpoints(mockConfig, log), &PointSuccessfullySentMock{}) mock := newTestTransaction() @@ -181,7 +182,7 @@ func TestWorkerPurgeOnStop(t *testing.T) { lowPrio := make(chan transaction.Transaction, 1) requeue := make(chan transaction.Transaction, 1) mockConfig := pkgconfig.Mock(t) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) w := NewWorker(mockConfig, log, highPrio, lowPrio, requeue, newBlockedEndpoints(mockConfig, log), &PointSuccessfullySentMock{}) // making stopChan non blocking on insert and closing stopped channel // to avoid blocking in the Stop method since we don't actually start diff --git a/comp/languagedetection/bundle_test.go b/comp/languagedetection/bundle_test.go index 308fc83cc296d..3c2e144639b28 100644 --- a/comp/languagedetection/bundle_test.go +++ b/comp/languagedetection/bundle_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/secrets/secretsimpl" "github.com/DataDog/datadog-agent/comp/core/telemetry" @@ -26,10 +26,10 @@ func TestBundleDependencies(t *testing.T) { config.Module, fx.Supply(config.Params{}), telemetry.Module, - log.Module, + logimpl.Module, fx.Provide(func() secrets.Component { return secretsimpl.NewMockSecretResolver() }), secretsimpl.MockModule, - fx.Supply(log.Params{}), + fx.Supply(logimpl.Params{}), workloadmeta.Module, fx.Supply(workloadmeta.NewParams()), fx.Invoke(func(client.Component) {}), diff --git a/comp/languagedetection/client/client_test.go b/comp/languagedetection/client/client_test.go index 18d369d9b72f0..990122a0cd57f 100644 --- a/comp/languagedetection/client/client_test.go +++ b/comp/languagedetection/client/client_test.go @@ -14,7 +14,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/telemetry" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/languagedetection/languagemodels" @@ -49,7 +49,7 @@ func newTestClient(t *testing.T) (*client, chan *pbgo.ParentLanguageAnnotationRe "language_detection.client_period": "50ms", }}), telemetry.MockModule, - log.MockModule, + logimpl.MockModule, fx.Supply(workloadmeta.NewParams()), workloadmeta.MockModuleV2, fx.Provide(func(m workloadmeta.Mock) workloadmeta.Component { @@ -86,7 +86,7 @@ func TestClientEnabled(t *testing.T) { "cluster_agent.enabled": testCase.clusterAgentEnabled, }}), telemetry.MockModule, - log.MockModule, + logimpl.MockModule, fx.Supply(workloadmeta.NewParams()), workloadmeta.MockModuleV2, fx.Provide(func(m workloadmeta.Mock) workloadmeta.Component { diff --git a/comp/logs/agent/serverless.go b/comp/logs/agent/serverless.go index 7b013bcb17975..4aa1c6e322b36 100644 --- a/comp/logs/agent/serverless.go +++ b/comp/logs/agent/serverless.go @@ -8,7 +8,7 @@ package agent import ( "context" - logComponent "github.com/DataDog/datadog-agent/comp/core/log" + logComponent "github.com/DataDog/datadog-agent/comp/core/log/logimpl" pkgConfig "github.com/DataDog/datadog-agent/pkg/config" "github.com/DataDog/datadog-agent/pkg/logs/service" "github.com/DataDog/datadog-agent/pkg/logs/sources" diff --git a/comp/metadata/host/host_test.go b/comp/metadata/host/host_test.go index 141084305d75c..633e67dca1dd4 100644 --- a/comp/metadata/host/host_test.go +++ b/comp/metadata/host/host_test.go @@ -13,7 +13,7 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/metadata/resources" "github.com/DataDog/datadog-agent/comp/metadata/resources/resourcesimpl" configUtils "github.com/DataDog/datadog-agent/pkg/config/utils" @@ -25,7 +25,7 @@ func TestNewHostProviderDefaultInterval(t *testing.T) { ret := newHostProvider( fxutil.Test[dependencies]( t, - log.MockModule, + logimpl.MockModule, config.MockModule, resourcesimpl.MockModule, fx.Replace(resources.MockParams{Data: nil}), @@ -49,7 +49,7 @@ func TestNewHostProviderCustomInterval(t *testing.T) { ret := newHostProvider( fxutil.Test[dependencies]( t, - log.MockModule, + logimpl.MockModule, config.MockModule, resourcesimpl.MockModule, fx.Replace(resources.MockParams{Data: nil}), @@ -74,7 +74,7 @@ func TestNewHostProviderInvalidCustomInterval(t *testing.T) { ret := newHostProvider( fxutil.Test[dependencies]( t, - log.MockModule, + logimpl.MockModule, config.MockModule, resourcesimpl.MockModule, fx.Replace(resources.MockParams{Data: nil}), diff --git a/comp/metadata/internal/util/inventory_payload_test.go b/comp/metadata/internal/util/inventory_payload_test.go index 1972ae1bbe6d4..f47a4e776b288 100644 --- a/comp/metadata/internal/util/inventory_payload_test.go +++ b/comp/metadata/internal/util/inventory_payload_test.go @@ -16,6 +16,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/flare/helpers" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/serializer" "github.com/DataDog/datadog-agent/pkg/serializer/marshaler" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -37,7 +38,7 @@ func (p *testPayload) SplitPayload(_ int) ([]marshaler.AbstractMarshaler, error) func getTestInventoryPayload(t *testing.T, confOverrides map[string]any) *InventoryPayload { i := CreateInventoryPayload( fxutil.Test[config.Component](t, config.MockModule, fx.Replace(config.MockParams{Overrides: confOverrides})), - fxutil.Test[log.Component](t, log.MockModule), + fxutil.Test[log.Component](t, logimpl.MockModule), &serializer.MockSerializer{}, func() marshaler.JSONMarshaler { return &testPayload{} }, "test.json", diff --git a/comp/metadata/inventoryagent/inventoryagent_test.go b/comp/metadata/inventoryagent/inventoryagent_test.go index c91bbd48a4018..965afbb65bf45 100644 --- a/comp/metadata/inventoryagent/inventoryagent_test.go +++ b/comp/metadata/inventoryagent/inventoryagent_test.go @@ -13,7 +13,7 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" "github.com/DataDog/datadog-agent/pkg/serializer" "github.com/DataDog/datadog-agent/pkg/util/flavor" @@ -27,7 +27,7 @@ func getTestInventoryPayload(t *testing.T, confOverrides map[string]any) *invent p := newInventoryAgentProvider( fxutil.Test[dependencies]( t, - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Replace(config.MockParams{Overrides: confOverrides}), fx.Provide(func() serializer.MetricSerializer { return &serializer.MockSerializer{} }), diff --git a/comp/metadata/inventoryhost/inventoryhostimpl/inventoryhost_test.go b/comp/metadata/inventoryhost/inventoryhostimpl/inventoryhost_test.go index 58b9e71631140..f8b9d2934a2d5 100644 --- a/comp/metadata/inventoryhost/inventoryhostimpl/inventoryhost_test.go +++ b/comp/metadata/inventoryhost/inventoryhostimpl/inventoryhost_test.go @@ -13,7 +13,7 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/metadata/host/utils" "github.com/DataDog/datadog-agent/pkg/gohai/cpu" "github.com/DataDog/datadog-agent/pkg/gohai/memory" @@ -115,7 +115,7 @@ func getTestInventoryHost(t *testing.T) *invHost { p := newInventoryHostProvider( fxutil.Test[dependencies]( t, - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Provide(func() serializer.MetricSerializer { return &serializer.MockSerializer{} }), ), diff --git a/comp/metadata/resources/resourcesimpl/resources_test.go b/comp/metadata/resources/resourcesimpl/resources_test.go index 967f3423d8b02..da94bb752a366 100644 --- a/comp/metadata/resources/resourcesimpl/resources_test.go +++ b/comp/metadata/resources/resourcesimpl/resources_test.go @@ -21,7 +21,6 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" configUtils "github.com/DataDog/datadog-agent/pkg/config/utils" "github.com/DataDog/datadog-agent/pkg/serializer" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -40,7 +39,7 @@ func TestConfDisabled(t *testing.T) { ret := newResourcesProvider( fxutil.Test[dependencies]( t, - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Replace(config.MockParams{Overrides: overrides}), fx.Provide(func() serializer.MetricSerializer { return nil }), @@ -64,7 +63,7 @@ func TestConfInterval(t *testing.T) { ret := newResourcesProvider( fxutil.Test[dependencies]( t, - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Replace(config.MockParams{Overrides: overrides}), fx.Provide(func() serializer.MetricSerializer { return nil }), @@ -95,7 +94,7 @@ func TestCollect(t *testing.T) { ret := newResourcesProvider( fxutil.Test[dependencies]( t, - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Provide(func() serializer.MetricSerializer { return s }), ), @@ -119,7 +118,7 @@ func TestCollectError(t *testing.T) { ret := newResourcesProvider( fxutil.Test[dependencies]( t, - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Provide(func() serializer.MetricSerializer { return s }), ), diff --git a/comp/metadata/runner/runnerimpl/runner_test.go b/comp/metadata/runner/runnerimpl/runner_test.go index 825bf9c84b054..11dc5532dffe6 100644 --- a/comp/metadata/runner/runnerimpl/runner_test.go +++ b/comp/metadata/runner/runnerimpl/runner_test.go @@ -12,7 +12,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/metadata/runner" "github.com/DataDog/datadog-agent/pkg/util/fxutil" "github.com/stretchr/testify/assert" @@ -30,7 +30,7 @@ func TestHandleProvider(t *testing.T) { r := createRunner( fxutil.Test[dependencies]( t, - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(NewProvider(provider)), )) @@ -52,7 +52,7 @@ func TestRunnerCreation(t *testing.T) { fxutil.Test[runner.Component]( t, fx.Supply(lc), - log.MockModule, + logimpl.MockModule, config.MockModule, Module, // Supplying our provider by using the helper function diff --git a/comp/netflow/config/config_test.go b/comp/netflow/config/config_test.go index 7c5bc1cbc0b46..87640f6cae5e9 100644 --- a/comp/netflow/config/config_test.go +++ b/comp/netflow/config/config_test.go @@ -6,11 +6,13 @@ package config import ( - "github.com/DataDog/datadog-agent/comp/core/log" - "github.com/DataDog/datadog-agent/pkg/util/fxutil" "strings" "testing" + "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" + "github.com/DataDog/datadog-agent/pkg/util/fxutil" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -19,7 +21,7 @@ import ( ) func TestReadConfig(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) var tests = []struct { name string diff --git a/comp/netflow/flowaggregator/aggregator_test.go b/comp/netflow/flowaggregator/aggregator_test.go index 4add7e552bf8b..815e7011f39f4 100644 --- a/comp/netflow/flowaggregator/aggregator_test.go +++ b/comp/netflow/flowaggregator/aggregator_test.go @@ -30,6 +30,7 @@ import ( "github.com/stretchr/testify/require" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" "github.com/DataDog/datadog-agent/pkg/epforwarder" "github.com/DataDog/datadog-agent/pkg/logs/message" @@ -163,7 +164,7 @@ func TestAggregator(t *testing.T) { epForwarder.EXPECT().SendEventPlatformEventBlocking(message.NewMessage(compactEvent.Bytes(), nil, "", 0), "network-devices-netflow").Return(nil).Times(1) epForwarder.EXPECT().SendEventPlatformEventBlocking(message.NewMessage(compactMetadataEvent.Bytes(), nil, "", 0), "network-devices-metadata").Return(nil).Times(1) - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) aggregator := NewFlowAggregator(sender, epForwarder, &conf, "my-hostname", logger) aggregator.FlushFlowsToSendInterval = 1 * time.Second @@ -265,7 +266,7 @@ func TestAggregator_withMockPayload(t *testing.T) { epForwarder.EXPECT().SendEventPlatformEventBlocking(message.NewMessage(compactMetadataEvent.Bytes(), nil, "", 0), "network-devices-metadata").Return(nil).Times(1) - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) aggregator := NewFlowAggregator(sender, epForwarder, &conf, "my-hostname", logger) aggregator.FlushFlowsToSendInterval = 1 * time.Second aggregator.TimeNowFunction = func() time.Time { @@ -325,7 +326,7 @@ func TestAggregator_withMockPayload(t *testing.T) { func TestFlowAggregator_flush_submitCollectorMetrics_error(t *testing.T) { // 1/ Arrange - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) var b bytes.Buffer w := bufio.NewWriter(&b) @@ -396,7 +397,7 @@ func TestFlowAggregator_submitCollectorMetrics(t *testing.T) { ctrl := gomock.NewController(t) epForwarder := epforwarder.NewMockEventPlatformForwarder(ctrl) - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) aggregator := NewFlowAggregator(sender, epForwarder, &conf, "my-hostname", logger) aggregator.goflowPrometheusGatherer = prometheus.GathererFunc(func() ([]*promClient.MetricFamily, error) { @@ -472,7 +473,7 @@ func TestFlowAggregator_submitCollectorMetrics_error(t *testing.T) { ctrl := gomock.NewController(t) epForwarder := epforwarder.NewMockEventPlatformForwarder(ctrl) - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) aggregator := NewFlowAggregator(sender, epForwarder, &conf, "my-hostname", logger) aggregator.goflowPrometheusGatherer = prometheus.GathererFunc(func() ([]*promClient.MetricFamily, error) { @@ -506,7 +507,7 @@ func TestFlowAggregator_sendExporterMetadata_multiplePayloads(t *testing.T) { ctrl := gomock.NewController(t) epForwarder := epforwarder.NewMockEventPlatformForwarder(ctrl) - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) aggregator := NewFlowAggregator(sender, epForwarder, &conf, "my-hostname", logger) @@ -590,7 +591,7 @@ func TestFlowAggregator_sendExporterMetadata_noPayloads(t *testing.T) { ctrl := gomock.NewController(t) epForwarder := epforwarder.NewMockEventPlatformForwarder(ctrl) - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) aggregator := NewFlowAggregator(sender, epForwarder, &conf, "my-hostname", logger) @@ -623,7 +624,7 @@ func TestFlowAggregator_sendExporterMetadata_invalidIPIgnored(t *testing.T) { ctrl := gomock.NewController(t) epForwarder := epforwarder.NewMockEventPlatformForwarder(ctrl) - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) aggregator := NewFlowAggregator(sender, epForwarder, &conf, "my-hostname", logger) now := time.Unix(1681295467, 0) @@ -707,7 +708,7 @@ func TestFlowAggregator_sendExporterMetadata_multipleNamespaces(t *testing.T) { ctrl := gomock.NewController(t) epForwarder := epforwarder.NewMockEventPlatformForwarder(ctrl) - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) aggregator := NewFlowAggregator(sender, epForwarder, &conf, "my-hostname", logger) now := time.Unix(1681295467, 0) @@ -809,7 +810,7 @@ func TestFlowAggregator_sendExporterMetadata_singleExporterIpWithMultipleFlowTyp ctrl := gomock.NewController(t) epForwarder := epforwarder.NewMockEventPlatformForwarder(ctrl) - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) aggregator := NewFlowAggregator(sender, epForwarder, &conf, "my-hostname", logger) @@ -878,7 +879,7 @@ func TestFlowAggregator_sendExporterMetadata_singleExporterIpWithMultipleFlowTyp } func TestFlowAggregator_getSequenceDelta(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) type round struct { flowsToFlush []*common.Flow expectedSequenceDelta map[sequenceDeltaKey]sequenceDeltaValue diff --git a/comp/netflow/flowaggregator/flowaccumulator_test.go b/comp/netflow/flowaggregator/flowaccumulator_test.go index 742029eb5d072..970ff6b04ec51 100644 --- a/comp/netflow/flowaggregator/flowaccumulator_test.go +++ b/comp/netflow/flowaggregator/flowaccumulator_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/netflow/common" "github.com/DataDog/datadog-agent/comp/netflow/portrollup" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -32,7 +33,7 @@ func setMockTimeNow(newTime time.Time) { } func Test_flowAccumulator_add(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) synFlag := uint32(2) ackFlag := uint32(16) synAckFlag := synFlag | ackFlag @@ -113,7 +114,7 @@ func Test_flowAccumulator_add(t *testing.T) { } func Test_flowAccumulator_portRollUp(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) synFlag := uint32(2) ackFlag := uint32(16) synAckFlag := synFlag | ackFlag @@ -216,7 +217,7 @@ func Test_flowAccumulator_portRollUp(t *testing.T) { } func Test_flowAccumulator_flush(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) timeNow = MockTimeNow zeroTime := time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC) flushInterval := 60 * time.Second diff --git a/comp/netflow/goflowlib/flowstate_test.go b/comp/netflow/goflowlib/flowstate_test.go index 30db04eb3dc34..0260b477f9eca 100644 --- a/comp/netflow/goflowlib/flowstate_test.go +++ b/comp/netflow/goflowlib/flowstate_test.go @@ -6,19 +6,21 @@ package goflowlib import ( - "github.com/DataDog/datadog-agent/comp/netflow/config" "testing" + "github.com/DataDog/datadog-agent/comp/netflow/config" + "github.com/stretchr/testify/assert" "go.uber.org/atomic" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/netflow/common" "github.com/DataDog/datadog-agent/pkg/util/fxutil" ) func TestStartFlowRoutine_invalidType(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) listenerErr := atomic.NewString("") listenerFlowCount := atomic.NewInt64(0) diff --git a/comp/netflow/server/server_test.go b/comp/netflow/server/server_test.go index 0f48c7ecdb817..ee0a55f54af1e 100644 --- a/comp/netflow/server/server_test.go +++ b/comp/netflow/server/server_test.go @@ -22,7 +22,7 @@ import ( "github.com/DataDog/datadog-agent/comp/aggregator/demultiplexer" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/hostname/hostnameimpl" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/ndmtmp/forwarder/forwarderimpl" @@ -67,7 +67,7 @@ var testOptions = fx.Options( nfconfig.MockModule, forwarderimpl.MockModule, hostnameimpl.MockModule, - log.MockModule, + logimpl.MockModule, demultiplexer.MockModule, defaultforwarder.MockModule, config.MockModule, diff --git a/comp/process/bundle_test.go b/comp/process/bundle_test.go index f8d72f197df8a..6bf1abef97300 100644 --- a/comp/process/bundle_test.go +++ b/comp/process/bundle_test.go @@ -13,7 +13,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" configComp "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/comp/process/runner" "github.com/DataDog/datadog-agent/comp/process/types" @@ -22,7 +22,7 @@ import ( var mockCoreBundleParams = core.BundleParams{ ConfigParams: configComp.NewParams("", configComp.WithConfigMissingOK(true)), - LogParams: log.ForOneShot("PROCESS", "trace", false), + LogParams: logimpl.ForOneShot("PROCESS", "trace", false), } func TestBundleDependencies(t *testing.T) { diff --git a/comp/remote-config/rcclient/rcclient_test.go b/comp/remote-config/rcclient/rcclient_test.go index d34820b9576a5..4524cbcf78331 100644 --- a/comp/remote-config/rcclient/rcclient_test.go +++ b/comp/remote-config/rcclient/rcclient_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/config" "github.com/DataDog/datadog-agent/pkg/config/model" "github.com/DataDog/datadog-agent/pkg/config/remote" @@ -64,7 +64,7 @@ func TestAgentConfigCallback(t *testing.T) { err := settings.RegisterRuntimeSetting(mockSettings) assert.NoError(t, err) - rc := fxutil.Test[Component](t, fx.Options(Module, log.MockModule)) + rc := fxutil.Test[Component](t, fx.Options(Module, logimpl.MockModule)) layerStartFlare := state.RawConfig{Config: []byte(`{"name": "layer1", "config": {"log_level": "debug"}}`)} layerEndFlare := state.RawConfig{Config: []byte(`{"name": "layer1", "config": {"log_level": ""}}`)} diff --git a/comp/trace/bundle_test.go b/comp/trace/bundle_test.go index 98377ab7cdccd..92c1885c1b0d7 100644 --- a/comp/trace/bundle_test.go +++ b/comp/trace/bundle_test.go @@ -10,7 +10,7 @@ import ( "os" "testing" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/stretchr/testify/require" "go.uber.org/fx" @@ -69,8 +69,8 @@ func TestMockBundleDependencies(t *testing.T) { } var traceMockBundle = core.MakeMockBundle( - fx.Provide(func() log.Params { - return log.ForDaemon("TRACE", "apm_config.log_file", config.DefaultLogFilePath) + fx.Provide(func() logimpl.Params { + return logimpl.ForDaemon("TRACE", "apm_config.log_file", config.DefaultLogFilePath) }), - log.TraceMockModule, + logimpl.TraceMockModule, ) diff --git a/pkg/aggregator/aggregator_test.go b/pkg/aggregator/aggregator_test.go index 9da6f3dda1fe3..f043e30ed9b35 100644 --- a/pkg/aggregator/aggregator_test.go +++ b/pkg/aggregator/aggregator_test.go @@ -18,7 +18,7 @@ import ( // 3p "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -71,7 +71,7 @@ func getAggregator() *BufferedAggregator { opts := DefaultAgentDemultiplexerOptions() opts.FlushInterval = 1 * time.Hour opts.DontStartForwarders = true - log := log.NewTemporaryLoggerWithoutInit() + log := logimpl.NewTemporaryLoggerWithoutInit() forwarder := defaultforwarder.NewDefaultForwarder(pkgconfig.Datadog, log, defaultforwarder.NewOptions(pkgconfig.Datadog, log, nil)) demux := InitAndStartAgentDemultiplexer(log, forwarder, opts, defaultHostname) @@ -107,7 +107,7 @@ func TestDeregisterCheckSampler(t *testing.T) { // - opts := demuxTestOptions() - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) demux := InitAndStartAgentDemultiplexerForTest(deps, opts, defaultHostname) defer demux.Stop(false) @@ -287,7 +287,7 @@ func TestSeriesTooManyTags(t *testing.T) { return func(t *testing.T) { s := &MockSerializerIterableSerie{} opts := demuxTestOptions() - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) demux := InitAndStartAgentDemultiplexerForTest(deps, opts, "") demux.sharedSerializer = s @@ -352,7 +352,7 @@ func TestDistributionsTooManyTags(t *testing.T) { return func(t *testing.T) { s := &MockSerializerIterableSerie{} opts := demuxTestOptions() - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) demux := InitAndStartAgentDemultiplexerForTest(deps, opts, "") demux.sharedSerializer = s @@ -408,7 +408,7 @@ func TestRecurrentSeries(t *testing.T) { s := &MockSerializerIterableSerie{} opts := demuxTestOptions() - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) demux := InitAndStartAgentDemultiplexerForTest(deps, opts, "") demux.aggregator.serializer = s @@ -594,7 +594,7 @@ func TestTimeSamplerFlush(t *testing.T) { s := &MockSerializerIterableSerie{} s.On("SendServiceChecks", mock.Anything).Return(nil) opts := demuxTestOptions() - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) demux := InitAndStartAgentDemultiplexerForTest(deps, opts, "") demux.aggregator.serializer = s diff --git a/pkg/aggregator/check_sampler_bench_test.go b/pkg/aggregator/check_sampler_bench_test.go index 34ef1ecd07823..5042fcd5636ee 100644 --- a/pkg/aggregator/check_sampler_bench_test.go +++ b/pkg/aggregator/check_sampler_bench_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" forwarder "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/pkg/aggregator/ckey" "github.com/DataDog/datadog-agent/pkg/aggregator/internal/tags" @@ -23,7 +24,7 @@ func benchmarkAddBucket(bucketValue int64, b *testing.B) { // flush and because the serializer is not initialized it panics with a nil. // For some reasons using InitAggregator[WithInterval] doesn't fix the problem, // but this do. - log := fxutil.Test[log.Component](b, log.MockModule) + log := fxutil.Test[log.Component](b, logimpl.MockModule) forwarderOpts := forwarder.NewOptionsWithResolvers(config.Datadog, log, resolver.NewSingleDomainResolvers(map[string][]string{"hello": {"world"}})) options := DefaultAgentDemultiplexerOptions() options.DontStartForwarders = true diff --git a/pkg/aggregator/demultiplexer_agent_test.go b/pkg/aggregator/demultiplexer_agent_test.go index 4b5f5ecdc36ed..1e853ab8f9325 100644 --- a/pkg/aggregator/demultiplexer_agent_test.go +++ b/pkg/aggregator/demultiplexer_agent_test.go @@ -14,6 +14,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/pkg/metrics" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -53,7 +54,7 @@ func TestDemuxNoAggOptionDisabled(t *testing.T) { require := require.New(t) opts := demuxTestOptions() - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := initAgentDemultiplexer(log, NewForwarderTest(log), opts, "") batch := testDemuxSamples(t) @@ -73,7 +74,7 @@ func TestDemuxNoAggOptionEnabled(t *testing.T) { opts := demuxTestOptions() mockSerializer := &MockSerializerIterableSerie{} opts.EnableNoAggregationPipeline = true - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := initAgentDemultiplexer(log, NewForwarderTest(log), opts, "") demux.statsd.noAggStreamWorker.serializer = mockSerializer // the no agg pipeline will use our mocked serializer @@ -99,7 +100,7 @@ func TestDemuxNoAggOptionEnabled(t *testing.T) { func TestDemuxNoAggOptionIsDisabledByDefault(t *testing.T) { opts := demuxTestOptions() - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) demux := InitAndStartAgentDemultiplexerForTest(deps, opts, "") require.False(t, demux.Options().EnableNoAggregationPipeline, "the no aggregation pipeline should be disabled by default") diff --git a/pkg/aggregator/demultiplexer_serverless.go b/pkg/aggregator/demultiplexer_serverless.go index 5621fda8e4f5d..07c330dcca347 100644 --- a/pkg/aggregator/demultiplexer_serverless.go +++ b/pkg/aggregator/demultiplexer_serverless.go @@ -10,6 +10,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" forwarder "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/pkg/aggregator/internal/tags" "github.com/DataDog/datadog-agent/pkg/config" @@ -39,7 +40,7 @@ type ServerlessDemultiplexer struct { // InitAndStartServerlessDemultiplexer creates and starts new Demultiplexer for the serverless agent. func InitAndStartServerlessDemultiplexer(keysPerDomain map[string][]string, forwarderTimeout time.Duration) *ServerlessDemultiplexer { bufferSize := config.Datadog.GetInt("aggregator_buffer_size") - log := log.NewTemporaryLoggerWithoutInit() + log := logimpl.NewTemporaryLoggerWithoutInit() forwarder := forwarder.NewSyncForwarder(config.Datadog, log, keysPerDomain, forwarderTimeout) serializer := serializer.NewSerializer(forwarder, nil) metricSamplePool := metrics.NewMetricSamplePool(MetricSamplePoolBatchSize, utils.IsTelemetryEnabled()) diff --git a/pkg/aggregator/demultiplexer_test.go b/pkg/aggregator/demultiplexer_test.go index de4c5e9d8558d..0da9027d0a459 100644 --- a/pkg/aggregator/demultiplexer_test.go +++ b/pkg/aggregator/demultiplexer_test.go @@ -13,6 +13,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -39,7 +40,7 @@ func TestDemuxIsSetAsGlobalInstance(t *testing.T) { require := require.New(t) opts := demuxTestOptions() - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) demux := InitAndStartAgentDemultiplexerForTest(deps, opts, "") require.NotNil(demux) @@ -54,7 +55,7 @@ func TestDemuxForwardersCreated(t *testing.T) { // forwarders since we're not in a cluster-agent environment opts := demuxTestOptions() - modules := fx.Options(defaultforwarder.MockModule, config.MockModule, log.MockModule) + modules := fx.Options(defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) deps := fxutil.Test[TestDeps](t, modules) demux := InitAndStartAgentDemultiplexerForTest(deps, opts, "") @@ -163,7 +164,7 @@ func TestDemuxSerializerCreated(t *testing.T) { // forwarders since we're not in a cluster-agent environment opts := demuxTestOptions() - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) demux := InitAndStartAgentDemultiplexerForTest(deps, opts, "") require.NotNil(demux) @@ -180,7 +181,7 @@ func TestDemuxFlushAggregatorToSerializer(t *testing.T) { opts := demuxTestOptions() opts.FlushInterval = time.Hour - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) demux := initAgentDemultiplexer(deps.Log, deps.SharedForwarder, opts, "") demux.Aggregator().tlmContainerTagsEnabled = false require.NotNil(demux) diff --git a/pkg/aggregator/mocksender/mocksender.go b/pkg/aggregator/mocksender/mocksender.go index 1197a5b9ee5a7..9ec7933e088f9 100644 --- a/pkg/aggregator/mocksender/mocksender.go +++ b/pkg/aggregator/mocksender/mocksender.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/mock" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" forwarder "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/aggregator/sender" @@ -31,7 +31,7 @@ func CreateDefaultDemultiplexer() *aggregator.AgentDemultiplexer { opts := aggregator.DefaultAgentDemultiplexerOptions() opts.FlushInterval = 1 * time.Hour opts.DontStartForwarders = true - log := log.NewTemporaryLoggerWithoutInit() + log := logimpl.NewTemporaryLoggerWithoutInit() sharedForwarder := forwarder.NewDefaultForwarder(config.Datadog, log, forwarder.NewOptions(config.Datadog, log, nil)) return aggregator.InitAndStartAgentDemultiplexer(log, sharedForwarder, opts, "") diff --git a/pkg/aggregator/sender_test.go b/pkg/aggregator/sender_test.go index 3d03c7822525e..a1a39d3b63f83 100644 --- a/pkg/aggregator/sender_test.go +++ b/pkg/aggregator/sender_test.go @@ -16,6 +16,7 @@ import ( "github.com/stretchr/testify/require" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" "github.com/DataDog/datadog-agent/pkg/metrics" "github.com/DataDog/datadog-agent/pkg/metrics/event" @@ -67,7 +68,7 @@ func assertAggSamplersLen(t *testing.T, agg *BufferedAggregator, n int) { func TestGetDefaultSenderReturnsSameSender(t *testing.T) { // this test not using anything global // - - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := testDemux(log) aggregatorInstance := demux.Aggregator() go aggregatorInstance.run() @@ -87,7 +88,7 @@ func TestGetDefaultSenderReturnsSameSender(t *testing.T) { func TestGetSenderWithDifferentIDsReturnsDifferentCheckSamplers(t *testing.T) { // this test not using anything global // - - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := testDemux(log) aggregatorInstance := demux.Aggregator() @@ -117,7 +118,7 @@ func TestGetSenderWithSameIDsReturnsSameSender(t *testing.T) { // this test not using anything global // - - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := testDemux(log) aggregatorInstance := demux.Aggregator() go aggregatorInstance.run() @@ -140,7 +141,7 @@ func TestDestroySender(t *testing.T) { // this test not using anything global // - - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := testDemux(log) aggregatorInstance := demux.Aggregator() go aggregatorInstance.run() @@ -170,7 +171,7 @@ func TestGetAndSetSender(t *testing.T) { // this test not using anything global // - - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := testDemux(log) itemChan := make(chan senderItem, 10) @@ -193,7 +194,7 @@ func TestGetSenderDefaultHostname(t *testing.T) { // this test not using anything global // - - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := testDemux(log) aggregatorInstance := demux.Aggregator() go aggregatorInstance.run() diff --git a/pkg/autodiscovery/providers/container_test.go b/pkg/autodiscovery/providers/container_test.go index a6b70180bbafa..4e7b024434fa6 100644 --- a/pkg/autodiscovery/providers/container_test.go +++ b/pkg/autodiscovery/providers/container_test.go @@ -14,7 +14,7 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors" "github.com/DataDog/datadog-agent/pkg/autodiscovery/integration" @@ -24,7 +24,7 @@ import ( func TestProcessEvents(t *testing.T) { store := fxutil.Test[workloadmeta.Mock](t, fx.Options( config.MockModule, - log.MockModule, + logimpl.MockModule, collectors.GetCatalog(), fx.Supply(workloadmeta.NewParams()), workloadmeta.MockModuleV2, @@ -413,7 +413,7 @@ func TestGenerateConfig(t *testing.T) { store := fxutil.Test[workloadmeta.Mock](t, fx.Options( config.MockModule, - log.MockModule, + logimpl.MockModule, fx.Replace(config.MockParams{Overrides: overrides}), collectors.GetCatalog(), fx.Supply(workloadmeta.NewParams()), diff --git a/pkg/cli/subcommands/check/command.go b/pkg/cli/subcommands/check/command.go index c0ea979833f5a..48715a09ca451 100644 --- a/pkg/cli/subcommands/check/command.go +++ b/pkg/cli/subcommands/check/command.go @@ -29,7 +29,7 @@ import ( "github.com/DataDog/datadog-agent/comp/aggregator/demultiplexer" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" @@ -125,7 +125,7 @@ func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command { ConfigParams: config.NewAgentParams(globalParams.ConfFilePath, config.WithConfigName(globalParams.ConfigName)), SecretParams: secrets.NewEnabledParams(), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.SysProbeConfFilePath)), - LogParams: log.ForOneShot(globalParams.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(globalParams.LoggerName, "off", true)}), core.Bundle, workloadmeta.Module, diff --git a/pkg/cli/subcommands/clusterchecks/command.go b/pkg/cli/subcommands/clusterchecks/command.go index 21bedb0188c3b..0d9b3b0e76050 100644 --- a/pkg/cli/subcommands/clusterchecks/command.go +++ b/pkg/cli/subcommands/clusterchecks/command.go @@ -18,6 +18,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/api/util" "github.com/DataDog/datadog-agent/pkg/clusteragent/clusterchecks/types" @@ -92,7 +93,7 @@ func bundleParams(globalParams GlobalParams) core.BundleParams { return core.BundleParams{ ConfigParams: config.NewClusterAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(loggerName, defaultLogLevel, true), + LogParams: logimpl.ForOneShot(loggerName, defaultLogLevel, true), } } diff --git a/pkg/cli/subcommands/config/command.go b/pkg/cli/subcommands/config/command.go index 70acd3fc1f5c2..216825709ffff 100644 --- a/pkg/cli/subcommands/config/command.go +++ b/pkg/cli/subcommands/config/command.go @@ -14,6 +14,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/api/util" "github.com/DataDog/datadog-agent/pkg/config/settings" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -59,7 +60,7 @@ func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command { fx.Supply(cliParams), fx.Supply(core.BundleParams{ ConfigParams: config.NewAgentParams(globalParams.ConfFilePath, config.WithConfigName(globalParams.ConfigName)), - LogParams: log.ForOneShot(globalParams.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(globalParams.LoggerName, "off", true)}), core.Bundle, ) } diff --git a/pkg/cli/subcommands/dcaconfigcheck/command.go b/pkg/cli/subcommands/dcaconfigcheck/command.go index a948dd9c5f067..f8dde8cbab141 100644 --- a/pkg/cli/subcommands/dcaconfigcheck/command.go +++ b/pkg/cli/subcommands/dcaconfigcheck/command.go @@ -14,6 +14,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/flare" "github.com/DataDog/datadog-agent/pkg/util/fxutil" ) @@ -46,7 +47,7 @@ func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command { fx.Supply(cliParams), fx.Supply(core.BundleParams{ ConfigParams: config.NewClusterAgentParams(globalParams.ConfFilePath), - LogParams: log.ForOneShot("CLUSTER", "off", true), + LogParams: logimpl.ForOneShot("CLUSTER", "off", true), }), core.Bundle, ) diff --git a/pkg/cli/subcommands/dcaflare/command.go b/pkg/cli/subcommands/dcaflare/command.go index 1bdc1666727d2..3b86730ad849d 100644 --- a/pkg/cli/subcommands/dcaflare/command.go +++ b/pkg/cli/subcommands/dcaflare/command.go @@ -21,7 +21,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/flare/helpers" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/api/util" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -86,7 +86,7 @@ func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewClusterAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(LoggerName, DefaultLogLevel, true), + LogParams: logimpl.ForOneShot(LoggerName, DefaultLogLevel, true), }), core.Bundle, diagnosesendermanagerimpl.Module, diff --git a/pkg/cli/subcommands/health/command.go b/pkg/cli/subcommands/health/command.go index 015554daec89f..566d7af74cc75 100644 --- a/pkg/cli/subcommands/health/command.go +++ b/pkg/cli/subcommands/health/command.go @@ -22,6 +22,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/api/util" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" "github.com/DataDog/datadog-agent/pkg/status/health" @@ -57,7 +58,7 @@ func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command { fx.Supply(cliParams), fx.Supply(core.BundleParams{ ConfigParams: config.NewAgentParams(globalParams.ConfFilePath, config.WithConfigName(globalParams.ConfigName)), - LogParams: log.ForOneShot(globalParams.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(globalParams.LoggerName, "off", true)}), core.Bundle, ) }, diff --git a/pkg/cli/subcommands/taggerlist/command.go b/pkg/cli/subcommands/taggerlist/command.go index 74b487d199a1d..81382a76e6f27 100644 --- a/pkg/cli/subcommands/taggerlist/command.go +++ b/pkg/cli/subcommands/taggerlist/command.go @@ -14,6 +14,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/api/util" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" tagger_api "github.com/DataDog/datadog-agent/pkg/tagger/api" @@ -59,7 +60,7 @@ func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command { globalParams.ConfFilePath, config.WithConfigName(globalParams.ConfigName), ), - LogParams: log.ForOneShot(globalParams.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(globalParams.LoggerName, "off", true)}), core.Bundle, ) }, diff --git a/pkg/cli/subcommands/workloadlist/command.go b/pkg/cli/subcommands/workloadlist/command.go index 7eb495a4b647f..3f321305fbfa1 100644 --- a/pkg/cli/subcommands/workloadlist/command.go +++ b/pkg/cli/subcommands/workloadlist/command.go @@ -15,6 +15,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/api/util" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -62,7 +63,7 @@ func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command { globalParams.ConfFilePath, config.WithConfigName(globalParams.ConfigName), ), - LogParams: log.ForOneShot(globalParams.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(globalParams.LoggerName, "off", true)}), core.Bundle, ) }, diff --git a/pkg/clusteragent/admission/mutate/auto_instrumentation_util_test.go b/pkg/clusteragent/admission/mutate/auto_instrumentation_util_test.go index 4d5450988f65b..be589a5be81d0 100644 --- a/pkg/clusteragent/admission/mutate/auto_instrumentation_util_test.go +++ b/pkg/clusteragent/admission/mutate/auto_instrumentation_util_test.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/languagedetection/languagemodels" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -83,7 +83,7 @@ func assertEqualLibInjection(actualLibs []libInfo, expectedLibs []libInfo) bool func TestGetLibListFromDeploymentAnnotations(t *testing.T) { mockStore := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(workloadmeta.NewParams()), workloadmeta.MockModuleV2, diff --git a/pkg/collector/collector_demux_test.go b/pkg/collector/collector_demux_test.go index d070c5814a2e6..4666e1e8d04f7 100644 --- a/pkg/collector/collector_demux_test.go +++ b/pkg/collector/collector_demux_test.go @@ -11,6 +11,7 @@ import ( "testing" "time" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -30,7 +31,7 @@ type CollectorDemuxTestSuite struct { } func (suite *CollectorDemuxTestSuite) SetupTest() { - log := fxutil.Test[log.Component](suite.T(), log.MockModule) + log := fxutil.Test[log.Component](suite.T(), logimpl.MockModule) suite.demux = aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, 100*time.Hour) suite.c = NewCollector(suite.demux).(*collector) diff --git a/pkg/collector/corechecks/containers/kubelet/provider/summary/provider_test.go b/pkg/collector/corechecks/containers/kubelet/provider/summary/provider_test.go index 98cb2d34c6b14..2f2d213f991b5 100644 --- a/pkg/collector/corechecks/containers/kubelet/provider/summary/provider_test.go +++ b/pkg/collector/corechecks/containers/kubelet/provider/summary/provider_test.go @@ -18,7 +18,7 @@ import ( "go.uber.org/fx" configcomp "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" "github.com/DataDog/datadog-agent/pkg/autodiscovery/common/types" @@ -323,7 +323,7 @@ func TestProvider_Provide(t *testing.T) { func creatFakeStore(t *testing.T) workloadmeta.Mock { store := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, configcomp.MockModule, fx.Supply(context.Background()), fx.Supply(workloadmeta.NewParams()), diff --git a/pkg/collector/corechecks/sbom/processor_test.go b/pkg/collector/corechecks/sbom/processor_test.go index f557b25eff472..f6dedde1616e4 100644 --- a/pkg/collector/corechecks/sbom/processor_test.go +++ b/pkg/collector/corechecks/sbom/processor_test.go @@ -25,7 +25,6 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" configcomp "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" "github.com/DataDog/datadog-agent/pkg/config" @@ -600,7 +599,7 @@ func TestProcessEvents(t *testing.T) { var SBOMsSent = atomic.NewInt32(0) workloadmetaStore := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, configcomp.MockModule, fx.Supply(context.Background()), fx.Supply(workloadmeta.NewParams()), diff --git a/pkg/collector/corechecks/snmp/snmp_test.go b/pkg/collector/corechecks/snmp/snmp_test.go index 20230753aae7f..ea17ba2716991 100644 --- a/pkg/collector/corechecks/snmp/snmp_test.go +++ b/pkg/collector/corechecks/snmp/snmp_test.go @@ -20,6 +20,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" @@ -55,7 +56,7 @@ type deps struct { } func createDeps(t *testing.T) deps { - return fxutil.Test[deps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + return fxutil.Test[deps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) } func Test_Run_simpleCase(t *testing.T) { diff --git a/pkg/logs/launchers/container/tailerfactory/file_test.go b/pkg/logs/launchers/container/tailerfactory/file_test.go index d0da0434dcb7e..0f69b234cf8a9 100644 --- a/pkg/logs/launchers/container/tailerfactory/file_test.go +++ b/pkg/logs/launchers/container/tailerfactory/file_test.go @@ -18,7 +18,6 @@ import ( "go.uber.org/fx" compConfig "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/comp/logs/agent/config" coreConfig "github.com/DataDog/datadog-agent/pkg/config" @@ -195,7 +194,7 @@ func TestMakeK8sSource(t *testing.T) { wildcard := filepath.Join(dir, "*.log") store := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, compConfig.MockModule, fx.Supply(context.Background()), fx.Supply(workloadmeta.NewParams()), @@ -252,7 +251,7 @@ func TestMakeK8sSource_pod_not_found(t *testing.T) { require.NoError(t, os.WriteFile(p, []byte("{}"), 0o666)) workloadmetaStore := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, compConfig.MockModule, fx.Supply(context.Background()), fx.Supply(workloadmeta.NewParams()), diff --git a/pkg/metadata/scheduler_test.go b/pkg/metadata/scheduler_test.go index 573acb2a9cbd6..41e9c5a71bd63 100644 --- a/pkg/metadata/scheduler_test.go +++ b/pkg/metadata/scheduler_test.go @@ -15,7 +15,7 @@ import ( "github.com/DataDog/datadog-agent/comp/aggregator/demultiplexer" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/serializer" @@ -229,5 +229,5 @@ type deps struct { func buildDeps(t *testing.T) deps { opts := aggregator.DefaultAgentDemultiplexerOptions() opts.DontStartForwarders = true - return fxutil.Test[deps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule, demultiplexer.MockModule) + return fxutil.Test[deps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule, demultiplexer.MockModule) } diff --git a/pkg/process/runner/submitter_test.go b/pkg/process/runner/submitter_test.go index 93233323961a5..9fac4daa944cb 100644 --- a/pkg/process/runner/submitter_test.go +++ b/pkg/process/runner/submitter_test.go @@ -16,6 +16,7 @@ import ( model "github.com/DataDog/agent-payload/v5/process" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/process/forwarders" ddconfig "github.com/DataDog/datadog-agent/pkg/config" "github.com/DataDog/datadog-agent/pkg/process/util/api/headers" @@ -339,5 +340,5 @@ func newSubmitterDepsWithConfig(t *testing.T, config ddconfig.Config) submitterD } func getForwardersMockModules(configOverrides map[string]interface{}) fx.Option { - return fx.Options(config.MockModule, fx.Replace(config.MockParams{Overrides: configOverrides}), forwarders.MockModule, log.MockModule) + return fx.Options(config.MockModule, fx.Replace(config.MockParams{Overrides: configOverrides}), forwarders.MockModule, logimpl.MockModule) } diff --git a/pkg/serverless/invocationlifecycle/lifecycle_test.go b/pkg/serverless/invocationlifecycle/lifecycle_test.go index b3eae5d5a7fb9..78704ecd678ed 100644 --- a/pkg/serverless/invocationlifecycle/lifecycle_test.go +++ b/pkg/serverless/invocationlifecycle/lifecycle_test.go @@ -12,6 +12,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/metrics" pb "github.com/DataDog/datadog-agent/pkg/proto/pbgo/trace" @@ -30,7 +31,7 @@ func TestGenerateEnhancedErrorMetricOnInvocationEnd(t *testing.T) { } mockProcessTrace := func(*api.Payload) {} mockDetectLambdaLibrary := func() bool { return true } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) endInvocationTime := time.Now() @@ -61,7 +62,7 @@ func TestStartExecutionSpanNoLambdaLibrary(t *testing.T) { extraTags := &logs.Tags{ Tags: []string{"functionname:test-function"}, } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) mockProcessTrace := func(*api.Payload) {} mockDetectLambdaLibrary := func() bool { return false } @@ -96,7 +97,7 @@ func TestStartExecutionSpanWithLambdaLibrary(t *testing.T) { extraTags := &logs.Tags{ Tags: []string{"functionname:test-function"}, } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) mockProcessTrace := func(*api.Payload) {} mockDetectLambdaLibrary := func() bool { return true } @@ -126,7 +127,7 @@ func TestEndExecutionSpanNoLambdaLibrary(t *testing.T) { extraTags := &logs.Tags{ Tags: []string{"functionname:test-function"}, } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) mockDetectLambdaLibrary := func() bool { return false } @@ -175,7 +176,7 @@ func TestEndExecutionSpanWithLambdaLibrary(t *testing.T) { extraTags := &logs.Tags{ Tags: []string{"functionname:test-function"}, } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) mockDetectLambdaLibrary := func() bool { return true } @@ -214,7 +215,7 @@ func TestEndExecutionSpanWithTraceMetadata(t *testing.T) { extraTags := &logs.Tags{ Tags: []string{"functionname:test-function"}, } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) mockDetectLambdaLibrary := func() bool { return false } @@ -271,7 +272,7 @@ func TestCompleteInferredSpanWithStartTime(t *testing.T) { extraTags := &logs.Tags{ Tags: []string{"functionname:test-function"}, } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) mockDetectLambdaLibrary := func() bool { return false } @@ -331,7 +332,7 @@ func TestCompleteInferredSpanWithOutStartTime(t *testing.T) { extraTags := &logs.Tags{ Tags: []string{"functionname:test-function"}, } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) mockDetectLambdaLibrary := func() bool { return false } @@ -417,7 +418,7 @@ func TestTriggerTypesLifecycleEventForAPIGateway5xxResponse(t *testing.T) { mockProcessTrace := func(payload *api.Payload) { tracePayload = payload } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -510,7 +511,7 @@ func TestTriggerTypesLifecycleEventForAPIGatewayNonProxy5xxResponse(t *testing.T mockProcessTrace := func(payload *api.Payload) { tracePayload = payload } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -599,7 +600,7 @@ func TestTriggerTypesLifecycleEventForAPIGatewayWebsocket5xxResponse(t *testing. mockProcessTrace := func(payload *api.Payload) { tracePayload = payload } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -686,7 +687,7 @@ func TestTriggerTypesLifecycleEventForALB5xxResponse(t *testing.T) { mockProcessTrace := func(payload *api.Payload) { tracePayload = payload } - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) diff --git a/pkg/serverless/logs/logs_test.go b/pkg/serverless/logs/logs_test.go index 1cc2cedabfc25..fcb6973bb25a8 100644 --- a/pkg/serverless/logs/logs_test.go +++ b/pkg/serverless/logs/logs_test.go @@ -20,6 +20,7 @@ import ( "github.com/stretchr/testify/require" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/logs/agent/config" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/metrics" @@ -187,7 +188,7 @@ func TestParseLogsAPIPayloadNotWellFormatedButNotRecoverable(t *testing.T) { } func TestProcessMessageValid(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -235,7 +236,7 @@ func TestProcessMessageValid(t *testing.T) { } func TestProcessMessageStartValid(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -269,7 +270,7 @@ func TestProcessMessageStartValid(t *testing.T) { } func TestProcessMessagePlatformRuntimeDoneValid(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) messageTime := time.Now() defer demux.Stop(false) @@ -304,7 +305,7 @@ func TestProcessMessagePlatformRuntimeDoneValid(t *testing.T) { } func TestProcessMessagePlatformRuntimeDonePreviousInvocation(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -340,7 +341,7 @@ func TestProcessMessagePlatformRuntimeDonePreviousInvocation(t *testing.T) { } func TestProcessMessageShouldNotProcessArnNotSet(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) message := &LambdaLogAPIMessage{ @@ -375,7 +376,7 @@ func TestProcessMessageShouldNotProcessArnNotSet(t *testing.T) { } func TestProcessMessageShouldNotProcessLogsDropped(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) message := &LambdaLogAPIMessage{ @@ -404,7 +405,7 @@ func TestProcessMessageShouldNotProcessLogsDropped(t *testing.T) { } func TestProcessMessageShouldProcessLogTypeFunctionOutOfMemory(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) message := &LambdaLogAPIMessage{ @@ -437,7 +438,7 @@ func TestProcessMessageShouldProcessLogTypeFunctionOutOfMemory(t *testing.T) { } func TestProcessMessageShouldProcessLogTypePlatformReportOutOfMemory(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) message := &LambdaLogAPIMessage{ @@ -673,7 +674,7 @@ func TestProcessLogMessageLogsNotEnabled(t *testing.T) { func TestProcessLogMessagesTimeoutLogFromReportLog(t *testing.T) { logChannel := make(chan *config.ChannelMessage) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -736,7 +737,7 @@ func TestProcessLogMessagesTimeoutLogFromReportLog(t *testing.T) { func TestProcessMultipleLogMessagesTimeoutLogFromReportLog(t *testing.T) { logChannel := make(chan *config.ChannelMessage) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -832,7 +833,7 @@ func TestProcessMultipleLogMessagesTimeoutLogFromReportLog(t *testing.T) { func TestProcessLogMessagesOutOfMemoryError(t *testing.T) { logChannel := make(chan *config.ChannelMessage) - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -1144,7 +1145,7 @@ func TestUnmarshalPlatformRuntimeDoneLogNotFatal(t *testing.T) { func TestRuntimeMetricsMatchLogs(t *testing.T) { // The test ensures that the values listed in the report log statement // matches the values of the metrics being reported. - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -1232,7 +1233,7 @@ func TestRuntimeMetricsMatchLogs(t *testing.T) { func TestRuntimeMetricsMatchLogsProactiveInit(t *testing.T) { // The test ensures that the values listed in the report log statement // matches the values of the metrics being reported. - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) @@ -1318,7 +1319,7 @@ func TestRuntimeMetricsMatchLogsProactiveInit(t *testing.T) { } func TestMultipleStartLogCollection(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) diff --git a/pkg/serverless/metrics/enhanced_metrics_test.go b/pkg/serverless/metrics/enhanced_metrics_test.go index 536203136c5bb..ea13252e8194e 100644 --- a/pkg/serverless/metrics/enhanced_metrics_test.go +++ b/pkg/serverless/metrics/enhanced_metrics_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/metrics" serverlessTags "github.com/DataDog/datadog-agent/pkg/serverless/tags" @@ -20,7 +21,7 @@ import ( ) func TestGenerateEnhancedMetricsFromFunctionLogOutOfMemory(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -52,7 +53,7 @@ func TestGenerateEnhancedMetricsFromFunctionLogOutOfMemory(t *testing.T) { } func TestGenerateEnhancedMetricsFromFunctionLogNoMetric(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -68,7 +69,7 @@ func TestGenerateEnhancedMetricsFromFunctionLogNoMetric(t *testing.T) { } func TestGenerateEnhancedMetricsFromReportLogColdStart(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -145,7 +146,7 @@ func TestGenerateEnhancedMetricsFromReportLogColdStart(t *testing.T) { } func TestGenerateEnhancedMetricsFromReportLogNoColdStart(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -215,7 +216,7 @@ func TestGenerateEnhancedMetricsFromReportLogNoColdStart(t *testing.T) { } func TestSendTimeoutEnhancedMetric(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -237,7 +238,7 @@ func TestSendTimeoutEnhancedMetric(t *testing.T) { } func TestSendInvocationEnhancedMetric(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -261,7 +262,7 @@ func TestSendInvocationEnhancedMetric(t *testing.T) { func TestDisableEnhancedMetrics(t *testing.T) { os.Setenv("DD_ENHANCED_METRICS", "false") defer os.Setenv("DD_ENHANCED_METRICS", "true") - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -275,7 +276,7 @@ func TestDisableEnhancedMetrics(t *testing.T) { } func TestSendOutOfMemoryEnhancedMetric(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -296,7 +297,7 @@ func TestSendOutOfMemoryEnhancedMetric(t *testing.T) { } func TestSendErrorsEnhancedMetric(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -357,7 +358,7 @@ func TestCalculateEstimatedCost(t *testing.T) { } func TestGenerateEnhancedMetricsFromRuntimeDoneLogNoStartDate(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -400,7 +401,7 @@ func TestGenerateEnhancedMetricsFromRuntimeDoneLogNoStartDate(t *testing.T) { } func TestGenerateEnhancedMetricsFromRuntimeDoneLogNoEndDate(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} @@ -443,7 +444,7 @@ func TestGenerateEnhancedMetricsFromRuntimeDoneLogNoEndDate(t *testing.T) { } func TestGenerateEnhancedMetricsFromRuntimeDoneLogOK(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) defer demux.Stop(false) tags := []string{"functionname:test-function"} diff --git a/pkg/snmp/traps/config/config_test.go b/pkg/snmp/traps/config/config_test.go index ad380588300c1..72912499c0be5 100644 --- a/pkg/snmp/traps/config/config_test.go +++ b/pkg/snmp/traps/config/config_test.go @@ -11,6 +11,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" ddconf "github.com/DataDog/datadog-agent/pkg/config" "github.com/DataDog/datadog-agent/pkg/util/fxutil" "github.com/gosnmp/gosnmp" @@ -52,7 +53,7 @@ func makeConfigWithGlobalNamespace(t *testing.T, trapConfig TrapsConfig, globalN } func TestFullConfig(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) rootConfig := makeConfig(t, TrapsConfig{ Port: 1234, Users: []UserV3{ @@ -104,7 +105,7 @@ func TestFullConfig(t *testing.T) { } func TestMinimalConfig(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) config, err := ReadConfig("", makeConfig(t, TrapsConfig{})) assert.NoError(t, err) assert.Equal(t, uint16(9162), config.Port) diff --git a/pkg/snmp/traps/formatter/formatter_test.go b/pkg/snmp/traps/formatter/formatter_test.go index e3e3329b02b9c..d88adba7da365 100644 --- a/pkg/snmp/traps/formatter/formatter_test.go +++ b/pkg/snmp/traps/formatter/formatter_test.go @@ -12,6 +12,7 @@ import ( "testing" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" oidresolver "github.com/DataDog/datadog-agent/pkg/snmp/traps/oid_resolver" "github.com/DataDog/datadog-agent/pkg/snmp/traps/packet" @@ -213,7 +214,7 @@ var ( func TestFormatPacketV1Generic(t *testing.T) { mockSender := mocksender.NewMockSender("snmp-traps-telemetry") mockSender.SetupAcceptAll() - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) defaultFormatter, _ := NewJSONFormatter(oidresolver.NewMockResolver(), mockSender, logger) packet := packet.CreateTestV1GenericPacket() @@ -259,7 +260,7 @@ func TestFormatPacketV1Generic(t *testing.T) { } func TestFormatPacketV1Specific(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) mockSender := mocksender.NewMockSender("snmp-traps-telemetry") mockSender.SetupAcceptAll() @@ -304,7 +305,7 @@ func TestFormatPacketV1Specific(t *testing.T) { } func TestFormatPacketToJSON(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) mockSender := mocksender.NewMockSender("snmp-traps-telemetry") mockSender.SetupAcceptAll() @@ -341,7 +342,7 @@ func TestFormatPacketToJSON(t *testing.T) { } func TestFormatPacketToJSONShouldFailIfNotEnoughVariables(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) mockSender := mocksender.NewMockSender("snmp-traps-telemetry") mockSender.SetupAcceptAll() @@ -374,7 +375,7 @@ func TestFormatPacketToJSONShouldFailIfNotEnoughVariables(t *testing.T) { } func TestNewJSONFormatterWithNilStillWorks(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) mockSender := mocksender.NewMockSender("snmp-traps-telemetry") mockSender.SetupAcceptAll() @@ -714,7 +715,7 @@ func TestFormatterWithResolverAndTrapV2(t *testing.T) { mockSender := mocksender.NewMockSender("snmp-traps-telemetry") mockSender.SetupAcceptAll() - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) resolver := oidresolver.NewMockResolver() formatter, err := NewJSONFormatter(resolver, mockSender, logger) require.NoError(t, err) @@ -738,7 +739,7 @@ func TestFormatterWithResolverAndTrapV2(t *testing.T) { } func TestFormatterWithResolverAndTrapV1Generic(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) myFakeVarTypeExpected := []interface{}{ "test0", "test1", @@ -875,7 +876,7 @@ func TestIsBitEnabled(t *testing.T) { } func TestEnrichBits(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) data := []struct { description string variable trapVariable @@ -1244,7 +1245,7 @@ func TestFormatterTelemetry(t *testing.T) { }, } - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) mockSender := mocksender.NewMockSender("snmp-traps-telemetry") mockSender.SetupAcceptAll() resolver := oidresolver.NewMockResolver() diff --git a/pkg/snmp/traps/forwarder/forwarder_test.go b/pkg/snmp/traps/forwarder/forwarder_test.go index 194aefb68e2ed..c884a765eca92 100644 --- a/pkg/snmp/traps/forwarder/forwarder_test.go +++ b/pkg/snmp/traps/forwarder/forwarder_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/require" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" "github.com/DataDog/datadog-agent/pkg/epforwarder" @@ -25,7 +26,7 @@ import ( var simpleUDPAddr = &net.UDPAddr{IP: net.IPv4(1, 1, 1, 1), Port: 161} func createForwarder(t *testing.T) (forwarder *TrapForwarder, err error) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) packetsIn := make(packet.PacketsChannel) mockSender := mocksender.NewMockSender("snmp-traps-listener") mockSender.SetupAcceptAll() diff --git a/pkg/snmp/traps/listener/listener_test.go b/pkg/snmp/traps/listener/listener_test.go index 95e8842809066..8fac5f7ac90ec 100644 --- a/pkg/snmp/traps/listener/listener_test.go +++ b/pkg/snmp/traps/listener/listener_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" "github.com/DataDog/datadog-agent/pkg/snmp/traps/config" packetModule "github.com/DataDog/datadog-agent/pkg/snmp/traps/packet" @@ -27,7 +28,7 @@ import ( const defaultTimeout = 1 * time.Second func listenerTestSetup(t *testing.T, config *config.TrapsConfig) (*mocksender.MockSender, *TrapListener, status.Manager) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) mockSender := mocksender.NewMockSender("snmp-traps-telemetry") mockSender.SetupAcceptAll() packetOutChan := make(packetModule.PacketsChannel, config.GetPacketChannelSize()) diff --git a/pkg/snmp/traps/oid_resolver/oid_resolver_test.go b/pkg/snmp/traps/oid_resolver/oid_resolver_test.go index bcbd4cf1da8d6..67a5ca15d9f3a 100644 --- a/pkg/snmp/traps/oid_resolver/oid_resolver_test.go +++ b/pkg/snmp/traps/oid_resolver/oid_resolver_test.go @@ -16,6 +16,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/util/fxutil" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" @@ -66,7 +67,7 @@ func TestDecoding(t *testing.T) { } func TestSortFiles(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) files := []fs.DirEntry{ MockedDirEntry{name: "totoro", isDir: false}, MockedDirEntry{name: "porco", isDir: false}, @@ -105,7 +106,7 @@ func TestSortFiles(t *testing.T) { } func TestResolverWithNonStandardOIDs(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) resolver := &MultiFilesOIDResolver{traps: make(TrapSpec), logger: logger} trapData := TrapDBFileContent{ Traps: TrapSpec{"1.3.6.1.4.1.8072.2.3.0.1": TrapMetadata{Name: "netSnmpExampleHeartbeat", MIBName: "NET-SNMP-EXAMPLES-MIB"}}, @@ -134,7 +135,7 @@ func TestResolverWithNonStandardOIDs(t *testing.T) { } func TestResolverWithConflictingTrapOID(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) resolver := &MultiFilesOIDResolver{traps: make(TrapSpec), logger: logger} trapDataA := TrapDBFileContent{ Traps: TrapSpec{"1.3.6.1.4.1.8072.2.3.0.1": TrapMetadata{Name: "foo", MIBName: "FOO-MIB"}}, @@ -151,7 +152,7 @@ func TestResolverWithConflictingTrapOID(t *testing.T) { } func TestResolverWithConflictingVariables(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) resolver := &MultiFilesOIDResolver{traps: make(TrapSpec), logger: logger} trapDataA := TrapDBFileContent{ Traps: TrapSpec{"1.3.6.1.4.1.8072.2.3.0.1": TrapMetadata{}}, @@ -182,7 +183,7 @@ func TestResolverWithConflictingVariables(t *testing.T) { } func TestResolverWithSuffixedVariable(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) resolver := &MultiFilesOIDResolver{traps: make(TrapSpec), logger: logger} updateResolverWithIntermediateJSONReader(t, resolver, dummyTrapDB) @@ -204,7 +205,7 @@ func TestResolverWithSuffixedVariable(t *testing.T) { } func TestResolverWithSuffixedVariableAndNodeConflict(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) resolver := &MultiFilesOIDResolver{traps: make(TrapSpec), logger: logger} trapDB := TrapDBFileContent{ Traps: TrapSpec{ @@ -242,7 +243,7 @@ func TestResolverWithSuffixedVariableAndNodeConflict(t *testing.T) { } func TestResolverWithNoMatchVariableShouldStopBeforeRoot(t *testing.T) { - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) resolver := &MultiFilesOIDResolver{traps: make(TrapSpec), logger: logger} trapDB := TrapDBFileContent{ Traps: TrapSpec{ diff --git a/pkg/snmp/traps/server_test.go b/pkg/snmp/traps/server_test.go index ab8cbb97b5f96..5483072306217 100644 --- a/pkg/snmp/traps/server_test.go +++ b/pkg/snmp/traps/server_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" "github.com/DataDog/datadog-agent/pkg/snmp/traps/config" "github.com/DataDog/datadog-agent/pkg/snmp/traps/formatter" @@ -24,7 +25,7 @@ func TestStartFailure(t *testing.T) { /* Start two servers with the same config to trigger an "address already in use" error. */ - logger := fxutil.Test[log.Component](t, log.MockModule) + logger := fxutil.Test[log.Component](t, logimpl.MockModule) freePort, err := ndmtestutils.GetFreePort() require.NoError(t, err) diff --git a/pkg/tagger/collectors/workloadmeta_test.go b/pkg/tagger/collectors/workloadmeta_test.go index 06ca9c8e1701b..6239f60dda201 100644 --- a/pkg/tagger/collectors/workloadmeta_test.go +++ b/pkg/tagger/collectors/workloadmeta_test.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/tagger/utils" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -60,7 +60,7 @@ func TestHandleKubePod(t *testing.T) { } store := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(workloadmeta.NewParams()), fx.Supply(context.Background()), @@ -469,7 +469,7 @@ func TestHandleECSTask(t *testing.T) { taggerEntityID := fmt.Sprintf("container_id://%s", containerID) store := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(workloadmeta.NewParams()), workloadmeta.MockModule, @@ -1166,7 +1166,7 @@ func TestHandleDelete(t *testing.T) { containerTaggerEntityID := fmt.Sprintf("container_id://%s", containerID) store := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(workloadmeta.NewParams()), workloadmeta.MockModule, @@ -1246,7 +1246,7 @@ func TestHandlePodWithDeletedContainer(t *testing.T) { collector := &WorkloadMetaCollector{ store: fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(workloadmeta.NewParams()), workloadmeta.MockModule, diff --git a/pkg/util/containers/metrics/containerd/collector_linux_test.go b/pkg/util/containers/metrics/containerd/collector_linux_test.go index de73521f12e31..58114de085349 100644 --- a/pkg/util/containers/metrics/containerd/collector_linux_test.go +++ b/pkg/util/containers/metrics/containerd/collector_linux_test.go @@ -25,7 +25,6 @@ import ( "google.golang.org/protobuf/types/known/anypb" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/util/containers/metrics/provider" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -281,7 +280,7 @@ func TestGetContainerStats_Containerd(t *testing.T) { // The container needs to exist in the workloadmeta store and have a // namespace. workloadmetaStore := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(context.Background()), fx.Supply(workloadmeta.NewParams()), @@ -381,7 +380,7 @@ func TestGetContainerNetworkStats_Containerd(t *testing.T) { // The container needs to exist in the workloadmeta store and have a // namespace. workloadmetaStore := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(context.Background()), fx.Supply(workloadmeta.NewParams()), diff --git a/pkg/util/containers/metrics/containerd/collector_windows_test.go b/pkg/util/containers/metrics/containerd/collector_windows_test.go index a40f264570d78..4609b2fcf7854 100644 --- a/pkg/util/containers/metrics/containerd/collector_windows_test.go +++ b/pkg/util/containers/metrics/containerd/collector_windows_test.go @@ -14,7 +14,6 @@ import ( "github.com/opencontainers/runtime-spec/specs-go" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/util/containers/metrics/provider" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -104,7 +103,7 @@ func TestGetContainerStats_Containerd(t *testing.T) { // The container needs to exist in the workloadmeta store and have a // namespace. workloadmetaStore := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(workloadmeta.NewParams()), workloadmeta.MockModuleV2, @@ -171,7 +170,7 @@ func TestGetContainerNetworkStats_Containerd(t *testing.T) { // The container needs to exist in the workloadmeta store and have a // namespace. workloadmetaStore := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(workloadmeta.NewParams()), workloadmeta.MockModuleV2, diff --git a/pkg/util/containers/metrics/docker/collector_test.go b/pkg/util/containers/metrics/docker/collector_test.go index 54609ba842560..e94238ee38d05 100644 --- a/pkg/util/containers/metrics/docker/collector_test.go +++ b/pkg/util/containers/metrics/docker/collector_test.go @@ -18,7 +18,6 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors" "github.com/DataDog/datadog-agent/pkg/util/containers/metrics/provider" @@ -85,7 +84,7 @@ func TestGetContainerIDForPID(t *testing.T) { // TODO(components): this test needs to rely on a workloadmeta.Component mock mockStore := fxutil.Test[workloadmeta.Mock](t, fx.Options( config.MockModule, - log.MockModule, + logimpl.MockModule, collectors.GetCatalog(), fx.Supply(workloadmeta.NewParams()), workloadmeta.MockModuleV2, diff --git a/pkg/util/trivy/cache_test.go b/pkg/util/trivy/cache_test.go index 26a282467def3..7a422123f1cc1 100644 --- a/pkg/util/trivy/cache_test.go +++ b/pkg/util/trivy/cache_test.go @@ -15,7 +15,6 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -223,7 +222,7 @@ func TestCustomBoltCache_DiskSizeLimit(t *testing.T) { func TestCustomBoltCache_GarbageCollector(t *testing.T) { // Create a workload meta global store containing two images with a distinct artifactID/blobs and a shared blob workloadmetaStore := fxutil.Test[workloadmeta.Mock](t, fx.Options( - log.MockModule, + logimpl.MockModule, config.MockModule, fx.Supply(context.Background()), fx.Supply(workloadmeta.NewParams()), diff --git a/test/integration/corechecks/docker/main_test.go b/test/integration/corechecks/docker/main_test.go index 24bc4ebae307a..b25f5c0b44ebe 100644 --- a/test/integration/corechecks/docker/main_test.go +++ b/test/integration/corechecks/docker/main_test.go @@ -117,7 +117,7 @@ func setup() error { fx.Supply(compcfg.NewAgentParams( "", compcfg.WithConfigMissingOK(true))), compcfg.Module, - fx.Supply(complog.ForOneShot("TEST", "info", false)), + fx.Supply(complogimpl.ForOneShot("TEST", "info", false)), complog.Module, fx.Supply(workloadmeta.NewParams()), collectors.GetCatalog(), From a72bb23fea2ed951b2b6b19d7f2a6d826c76b987 Mon Sep 17 00:00:00 2001 From: Olivier G Date: Thu, 30 Nov 2023 11:04:05 +0100 Subject: [PATCH 3/7] Add missing files --- cmd/agent/command/command.go | 4 ++-- cmd/agent/subcommands/configcheck/command.go | 4 ++-- cmd/agent/subcommands/diagnose/command.go | 3 ++- cmd/agent/subcommands/dogstatsd/command.go | 6 +++--- cmd/agent/subcommands/flare/command.go | 3 ++- cmd/agent/subcommands/hostname/command.go | 3 ++- cmd/agent/subcommands/jmx/command.go | 4 ++-- cmd/agent/subcommands/run/command.go | 3 ++- cmd/agent/subcommands/run/command_windows.go | 3 ++- cmd/agent/subcommands/snmp/command.go | 4 ++-- cmd/agent/subcommands/status/command.go | 3 ++- .../subcommands/run/command.go | 3 ++- .../subcommands/compliance/command.go | 4 ++-- .../subcommands/diagnose/command.go | 4 ++-- .../subcommands/metamap/command.go | 3 ++- cmd/cluster-agent/subcommands/start/command.go | 3 ++- cmd/cluster-agent/subcommands/status/command.go | 3 ++- cmd/dogstatsd/subcommands/start/command.go | 2 +- cmd/otel-agent/main.go | 3 ++- cmd/process-agent/command/command.go | 7 ++++--- cmd/process-agent/subcommands/check/check.go | 3 ++- cmd/security-agent/main_windows.go | 3 ++- cmd/security-agent/subcommands/check/command.go | 5 +++-- .../subcommands/compliance/command.go | 3 ++- cmd/security-agent/subcommands/config/config.go | 9 +++++---- cmd/security-agent/subcommands/flare/command.go | 3 ++- .../subcommands/runtime/activity_dump.go | 11 ++++++----- .../subcommands/runtime/command.go | 17 +++++++++-------- .../subcommands/runtime/deprecated_commands.go | 6 +++--- .../subcommands/runtime/security_profile.go | 7 ++++--- cmd/security-agent/subcommands/start/command.go | 3 ++- .../subcommands/status/command.go | 3 ++- .../subcommands/version/command.go | 3 ++- cmd/serverless-init/metric/metric_test.go | 7 ++++--- cmd/system-probe/subcommands/config/command.go | 4 ++-- cmd/system-probe/subcommands/debug/command.go | 4 ++-- .../subcommands/modrestart/command.go | 4 ++-- cmd/system-probe/subcommands/run/command.go | 13 +++++++------ cmd/systray/command/command.go | 8 ++++---- cmd/trace-agent/subcommands/info/command.go | 2 +- cmd/trace-agent/subcommands/run/command.go | 8 ++++---- 41 files changed, 112 insertions(+), 86 deletions(-) diff --git a/cmd/agent/command/command.go b/cmd/agent/command/command.go index c3c28178a118e..fab290e2d3d4f 100644 --- a/cmd/agent/command/command.go +++ b/cmd/agent/command/command.go @@ -15,7 +15,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" ) const ( @@ -47,7 +47,7 @@ type SubcommandFactory func(globalParams *GlobalParams) []*cobra.Command func GetDefaultCoreBundleParams(globalParams *GlobalParams) core.BundleParams { return core.BundleParams{ ConfigParams: config.NewAgentParams(globalParams.ConfFilePath), - LogParams: log.ForOneShot(LoggerName, "off", true)} + LogParams: logimpl.ForOneShot(LoggerName, "off", true)} } // MakeCommand makes the top-level Cobra command for this app. diff --git a/cmd/agent/subcommands/configcheck/command.go b/cmd/agent/subcommands/configcheck/command.go index bf4cf2dd2e549..8d8d0d56f75b5 100644 --- a/cmd/agent/subcommands/configcheck/command.go +++ b/cmd/agent/subcommands/configcheck/command.go @@ -17,7 +17,7 @@ import ( "github.com/DataDog/datadog-agent/cmd/agent/command" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/flare" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -47,7 +47,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot("CORE", "off", true)}), + LogParams: logimpl.ForOneShot("CORE", "off", true)}), core.Bundle, ) }, diff --git a/cmd/agent/subcommands/diagnose/command.go b/cmd/agent/subcommands/diagnose/command.go index b0cb962464311..d88255b8d0648 100644 --- a/cmd/agent/subcommands/diagnose/command.go +++ b/cmd/agent/subcommands/diagnose/command.go @@ -18,6 +18,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/api/util" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" pkgdiagnose "github.com/DataDog/datadog-agent/pkg/diagnose" @@ -78,7 +79,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(cliParams), fx.Supply(core.BundleParams{ ConfigParams: config.NewAgentParams(globalParams.ConfFilePath), - LogParams: log.ForOneShot("CORE", "off", true)}), + LogParams: logimpl.ForOneShot("CORE", "off", true)}), core.Bundle, diagnosesendermanagerimpl.Module, ) diff --git a/cmd/agent/subcommands/dogstatsd/command.go b/cmd/agent/subcommands/dogstatsd/command.go index 48ef84f0ac0e9..bfb0295f5453f 100644 --- a/cmd/agent/subcommands/dogstatsd/command.go +++ b/cmd/agent/subcommands/dogstatsd/command.go @@ -22,7 +22,7 @@ import ( "github.com/DataDog/datadog-agent/cmd/agent/command" "github.com/DataDog/datadog-agent/comp/core" cconfig "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/api/util" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -52,7 +52,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(&topFlags), fx.Supply(core.BundleParams{ ConfigParams: cconfig.NewAgentParams(globalParams.ConfFilePath), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) }, @@ -70,7 +70,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { return fxutil.OneShot(dumpContexts, fx.Supply(core.BundleParams{ ConfigParams: cconfig.NewAgentParams(globalParams.ConfFilePath), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) diff --git a/cmd/agent/subcommands/flare/command.go b/cmd/agent/subcommands/flare/command.go index 9e14c65919720..a9097d669e48b 100644 --- a/cmd/agent/subcommands/flare/command.go +++ b/cmd/agent/subcommands/flare/command.go @@ -27,6 +27,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/flare" "github.com/DataDog/datadog-agent/comp/core/flare/helpers" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" @@ -84,7 +85,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { ConfigParams: config, SecretParams: secrets.NewEnabledParams(), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.SysProbeConfFilePath)), - LogParams: log.ForOneShot(command.LoggerName, "off", false), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", false), }), fx.Supply(flare.NewLocalParams( commonpath.GetDistPath(), diff --git a/cmd/agent/subcommands/hostname/command.go b/cmd/agent/subcommands/hostname/command.go index a5e9fca7f19ea..27ffbd2e8c85c 100644 --- a/cmd/agent/subcommands/hostname/command.go +++ b/cmd/agent/subcommands/hostname/command.go @@ -17,6 +17,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/util/fxutil" "github.com/DataDog/datadog-agent/pkg/util/hostname" ) @@ -40,7 +41,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(cliParams), fx.Supply(core.BundleParams{ ConfigParams: config.NewAgentParams(globalParams.ConfFilePath), - LogParams: log.ForOneShot(command.LoggerName, "off", false)}), // never output anything but hostname + LogParams: logimpl.ForOneShot(command.LoggerName, "off", false)}), // never output anything but hostname core.Bundle, ) }, diff --git a/cmd/agent/subcommands/jmx/command.go b/cmd/agent/subcommands/jmx/command.go index 909c6ca3e9cc8..a4689518587e7 100644 --- a/cmd/agent/subcommands/jmx/command.go +++ b/cmd/agent/subcommands/jmx/command.go @@ -26,7 +26,7 @@ import ( "github.com/DataDog/datadog-agent/comp/aggregator/diagnosesendermanager/diagnosesendermanagerimpl" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors" @@ -93,7 +93,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { params := core.BundleParams{ ConfigParams: config.NewAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, cliParams.jmxLogLevel, false)} + LogParams: logimpl.ForOneShot(command.LoggerName, cliParams.jmxLogLevel, false)} if cliParams.logFile != "" { params.LogParams.LogToFile(cliParams.logFile) } diff --git a/cmd/agent/subcommands/run/command.go b/cmd/agent/subcommands/run/command.go index 54650cee453a3..d689c9ba3f0f7 100644 --- a/cmd/agent/subcommands/run/command.go +++ b/cmd/agent/subcommands/run/command.go @@ -43,6 +43,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/flare" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" @@ -156,7 +157,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { ConfigParams: config.NewAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.SysProbeConfFilePath)), - LogParams: log.ForDaemon(command.LoggerName, "log_file", path.DefaultLogFile), + LogParams: logimpl.ForDaemon(command.LoggerName, "log_file", path.DefaultLogFile), }), getSharedFxOption(), getPlatformModules(), diff --git a/cmd/agent/subcommands/run/command_windows.go b/cmd/agent/subcommands/run/command_windows.go index 7e88d057bda77..222850357b415 100644 --- a/cmd/agent/subcommands/run/command_windows.go +++ b/cmd/agent/subcommands/run/command_windows.go @@ -33,6 +33,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/flare" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" @@ -142,7 +143,7 @@ func StartAgentWithDefaults(ctxChan <-chan context.Context) (<-chan error, error ConfigParams: config.NewAgentParams(""), SecretParams: secrets.NewEnabledParams(), SysprobeConfigParams: sysprobeconfigimpl.NewParams(), - LogParams: log.ForDaemon(command.LoggerName, "log_file", path.DefaultLogFile), + LogParams: logimpl.ForDaemon(command.LoggerName, "log_file", path.DefaultLogFile), }), getSharedFxOption(), getPlatformModules(), diff --git a/cmd/agent/subcommands/snmp/command.go b/cmd/agent/subcommands/snmp/command.go index cef7b3e44b7ed..af17748969af5 100644 --- a/cmd/agent/subcommands/snmp/command.go +++ b/cmd/agent/subcommands/snmp/command.go @@ -21,7 +21,7 @@ import ( "github.com/DataDog/datadog-agent/cmd/agent/command" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" utilFunc "github.com/DataDog/datadog-agent/pkg/snmp/gosnmplib" parse "github.com/DataDog/datadog-agent/pkg/snmp/snmpparse" @@ -99,7 +99,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) }, diff --git a/cmd/agent/subcommands/status/command.go b/cmd/agent/subcommands/status/command.go index 88b30ee873dc1..07a6a974474ce 100644 --- a/cmd/agent/subcommands/status/command.go +++ b/cmd/agent/subcommands/status/command.go @@ -22,6 +22,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" "github.com/DataDog/datadog-agent/pkg/api/util" @@ -69,7 +70,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewAgentParams(globalParams.ConfFilePath), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.SysProbeConfFilePath)), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) }, diff --git a/cmd/cluster-agent-cloudfoundry/subcommands/run/command.go b/cmd/cluster-agent-cloudfoundry/subcommands/run/command.go index 1f6bdac44d990..2c96e1ee2e2ef 100644 --- a/cmd/cluster-agent-cloudfoundry/subcommands/run/command.go +++ b/cmd/cluster-agent-cloudfoundry/subcommands/run/command.go @@ -28,6 +28,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors" @@ -61,7 +62,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewClusterAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForDaemon(command.LoggerName, "log_file", path.DefaultDCALogFile), + LogParams: logimpl.ForDaemon(command.LoggerName, "log_file", path.DefaultDCALogFile), }), core.Bundle, forwarder.Bundle, diff --git a/cmd/cluster-agent/subcommands/compliance/command.go b/cmd/cluster-agent/subcommands/compliance/command.go index dd261dfbe9f61..fa438cff1813e 100644 --- a/cmd/cluster-agent/subcommands/compliance/command.go +++ b/cmd/cluster-agent/subcommands/compliance/command.go @@ -15,7 +15,7 @@ import ( "github.com/DataDog/datadog-agent/cmd/security-agent/subcommands/check" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" ) // Commands returns a slice of subcommands for the 'cluster-agent' command. @@ -27,7 +27,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { bundleParams := core.BundleParams{ ConfigParams: config.NewClusterAgentParams(""), - LogParams: log.ForOneShot(command.LoggerName, command.DefaultLogLevel, true), + LogParams: logimpl.ForOneShot(command.LoggerName, command.DefaultLogLevel, true), } complianceCmd.AddCommand(check.ClusterAgentCommands(bundleParams)...) diff --git a/cmd/cluster-agent/subcommands/diagnose/command.go b/cmd/cluster-agent/subcommands/diagnose/command.go index e58c5c17a123c..7c2b2302281e8 100644 --- a/cmd/cluster-agent/subcommands/diagnose/command.go +++ b/cmd/cluster-agent/subcommands/diagnose/command.go @@ -18,7 +18,7 @@ import ( "github.com/DataDog/datadog-agent/comp/aggregator/diagnosesendermanager/diagnosesendermanagerimpl" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/diagnose" "github.com/DataDog/datadog-agent/pkg/diagnose/diagnosis" @@ -36,7 +36,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewClusterAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", true), // no need to show regular logs + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true), // no need to show regular logs }), core.Bundle, diagnosesendermanagerimpl.Module, diff --git a/cmd/cluster-agent/subcommands/metamap/command.go b/cmd/cluster-agent/subcommands/metamap/command.go index 15375b4a80f72..75f0ecb44e0b4 100644 --- a/cmd/cluster-agent/subcommands/metamap/command.go +++ b/cmd/cluster-agent/subcommands/metamap/command.go @@ -18,6 +18,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/api/util" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -47,7 +48,7 @@ as well as which services are serving the pods. Or the deployment name for the p fx.Supply(core.BundleParams{ ConfigParams: config.NewClusterAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, command.DefaultLogLevel, true), + LogParams: logimpl.ForOneShot(command.LoggerName, command.DefaultLogLevel, true), }), core.Bundle, ) diff --git a/cmd/cluster-agent/subcommands/start/command.go b/cmd/cluster-agent/subcommands/start/command.go index 85dfb0523e0a5..1b8d89886c6d4 100644 --- a/cmd/cluster-agent/subcommands/start/command.go +++ b/cmd/cluster-agent/subcommands/start/command.go @@ -29,6 +29,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/telemetry" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" @@ -83,7 +84,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewClusterAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForDaemon(command.LoggerName, "log_file", path.DefaultDCALogFile), + LogParams: logimpl.ForDaemon(command.LoggerName, "log_file", path.DefaultDCALogFile), }), core.Bundle, forwarder.Bundle, diff --git a/cmd/cluster-agent/subcommands/status/command.go b/cmd/cluster-agent/subcommands/status/command.go index 8d8460c56b9d6..4e97941b1924f 100644 --- a/cmd/cluster-agent/subcommands/status/command.go +++ b/cmd/cluster-agent/subcommands/status/command.go @@ -21,6 +21,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/api/util" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -47,7 +48,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewClusterAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, command.DefaultLogLevel, true), + LogParams: logimpl.ForOneShot(command.LoggerName, command.DefaultLogLevel, true), }), core.Bundle, ) diff --git a/cmd/dogstatsd/subcommands/start/command.go b/cmd/dogstatsd/subcommands/start/command.go index b16bb3b61711f..65986bcd9a59a 100644 --- a/cmd/dogstatsd/subcommands/start/command.go +++ b/cmd/dogstatsd/subcommands/start/command.go @@ -20,7 +20,7 @@ import ( "github.com/DataDog/datadog-agent/comp/aggregator/demultiplexer" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" - logComponent "github.com/DataDog/datadog-agent/comp/core/log" + logComponent "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/secrets/secretsimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" diff --git a/cmd/otel-agent/main.go b/cmd/otel-agent/main.go index 8fa2a0bacbddb..65b806ba5c3d9 100644 --- a/cmd/otel-agent/main.go +++ b/cmd/otel-agent/main.go @@ -21,6 +21,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" corelog "github.com/DataDog/datadog-agent/comp/core/log" + corelogimpl "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/forwarder" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" @@ -67,7 +68,7 @@ func main() { core.BundleParams{ ConfigParams: config.NewAgentParams(*cfgPath), SecretParams: secrets.NewEnabledParams(), - LogParams: corelog.ForOneShot(loggerName, "debug", true), + LogParams: corelogimpl.ForOneShot(loggerName, "debug", true), }, ), fx.Provide(newForwarderParams), diff --git a/cmd/process-agent/command/command.go b/cmd/process-agent/command/command.go index 1847e65c4231e..28cd6e1d3c738 100644 --- a/cmd/process-agent/command/command.go +++ b/cmd/process-agent/command/command.go @@ -16,6 +16,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" configComponent "github.com/DataDog/datadog-agent/comp/core/config" logComponent "github.com/DataDog/datadog-agent/comp/core/log" + logComponentimpl "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" "github.com/DataDog/datadog-agent/pkg/config" @@ -25,10 +26,10 @@ import ( const LoggerName config.LoggerName = "PROCESS" // DaemonLogParams are the log params should be given to the `core.BundleParams` for when the process agent is running as a daemon -var DaemonLogParams = logComponent.ForDaemon(string(LoggerName), "process_config.log_file", config.DefaultProcessAgentLogFile) +var DaemonLogParams = logComponentimpl.ForDaemon(string(LoggerName), "process_config.log_file", config.DefaultProcessAgentLogFile) // OneShotLogParams are the log params that are given to commands -var OneShotLogParams = logComponent.ForOneShot(string(LoggerName), "info", true) +var OneShotLogParams = logComponentimpl.ForOneShot(string(LoggerName), "info", true) // GlobalParams contains the values of agent-global Cobra flags. // @@ -146,6 +147,6 @@ func GetCoreBundleParamsForOneShot(globalParams *GlobalParams) core.BundleParams ConfigParams: configComponent.NewAgentParams(globalParams.ConfFilePath), SecretParams: secrets.NewEnabledParams(), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.SysProbeConfFilePath)), - LogParams: logComponent.ForOneShot(string(LoggerName), "info", true), + LogParams: logComponentimpl.ForOneShot(string(LoggerName), "info", true), } } diff --git a/cmd/process-agent/subcommands/check/check.go b/cmd/process-agent/subcommands/check/check.go index 94a8fedc487f2..fd28b5df183ed 100644 --- a/cmd/process-agent/subcommands/check/check.go +++ b/cmd/process-agent/subcommands/check/check.go @@ -23,6 +23,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors" @@ -86,7 +87,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { // Disable logging if `--json` is specified. This way the check command will output proper json. if cliParams.checkOutputJSON { - bundleParams.LogParams = log.ForOneShot(string(command.LoggerName), "off", true) + bundleParams.LogParams = logimpl.ForOneShot(string(command.LoggerName), "off", true) } return fxutil.OneShot(runCheckCmd, diff --git a/cmd/security-agent/main_windows.go b/cmd/security-agent/main_windows.go index 13279d48d5045..17d0ffc7b9775 100644 --- a/cmd/security-agent/main_windows.go +++ b/cmd/security-agent/main_windows.go @@ -25,6 +25,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" @@ -95,7 +96,7 @@ func (s *service) Run(svcctx context.Context) error { ConfigParams: config.NewSecurityAgentParams(defaultSecurityAgentConfigFilePaths), SecretParams: secrets.NewEnabledParams(), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(defaultSysProbeConfPath)), - LogParams: log.ForDaemon(command.LoggerName, "security_agent.log_file", pkgconfig.DefaultSecurityAgentLogFile), + LogParams: logimpl.ForDaemon(command.LoggerName, "security_agent.log_file", pkgconfig.DefaultSecurityAgentLogFile), }), core.Bundle, dogstatsd.ClientBundle, diff --git a/cmd/security-agent/subcommands/check/command.go b/cmd/security-agent/subcommands/check/command.go index ce00b27fddea6..07725aacc060c 100644 --- a/cmd/security-agent/subcommands/check/command.go +++ b/cmd/security-agent/subcommands/check/command.go @@ -28,6 +28,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" "github.com/DataDog/datadog-agent/comp/dogstatsd" @@ -65,7 +66,7 @@ func SecurityAgentCommands(globalParams *command.GlobalParams) []*cobra.Command ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.SysProbeConfFilePath)), - LogParams: log.ForOneShot(command.LoggerName, "info", true), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true), } }) } @@ -89,7 +90,7 @@ func commandsWrapped(bundleParamsFactory func() core.BundleParams) []*cobra.Comm bundleParams := bundleParamsFactory() if checkArgs.verbose { - bundleParams.LogParams = log.ForOneShot(bundleParams.LogParams.LoggerName(), "trace", true) + bundleParams.LogParams = logimpl.ForOneShot(bundleParams.LogParams.LoggerName(), "trace", true) } return fxutil.OneShot(RunCheck, diff --git a/cmd/security-agent/subcommands/compliance/command.go b/cmd/security-agent/subcommands/compliance/command.go index 080e2638945bd..08d15289d00bc 100644 --- a/cmd/security-agent/subcommands/compliance/command.go +++ b/cmd/security-agent/subcommands/compliance/command.go @@ -19,6 +19,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/compliance" "github.com/DataDog/datadog-agent/pkg/security/common" @@ -62,7 +63,7 @@ func complianceEventCommand(globalParams *command.GlobalParams) *cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true), }), core.Bundle, ) diff --git a/cmd/security-agent/subcommands/config/config.go b/cmd/security-agent/subcommands/config/config.go index 99d5e8485a0ae..f63fe01129fbf 100644 --- a/cmd/security-agent/subcommands/config/config.go +++ b/cmd/security-agent/subcommands/config/config.go @@ -18,6 +18,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/api/util" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -58,7 +59,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) }, @@ -77,7 +78,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) }, @@ -97,7 +98,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) }, @@ -117,7 +118,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) }, diff --git a/cmd/security-agent/subcommands/flare/command.go b/cmd/security-agent/subcommands/flare/command.go index af7736535ebfd..c92b2f082d432 100644 --- a/cmd/security-agent/subcommands/flare/command.go +++ b/cmd/security-agent/subcommands/flare/command.go @@ -19,6 +19,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/flare/helpers" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/api/util" "github.com/DataDog/datadog-agent/pkg/flare" @@ -54,7 +55,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths, config.WithIgnoreErrors(true)), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) }, diff --git a/cmd/security-agent/subcommands/runtime/activity_dump.go b/cmd/security-agent/subcommands/runtime/activity_dump.go index 976973543f200..4b51a37d5b71d 100644 --- a/cmd/security-agent/subcommands/runtime/activity_dump.go +++ b/cmd/security-agent/subcommands/runtime/activity_dump.go @@ -21,6 +21,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" secagent "github.com/DataDog/datadog-agent/pkg/security/agent" secconfig "github.com/DataDog/datadog-agent/pkg/security/config" @@ -72,7 +73,7 @@ func listCommands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, @@ -95,7 +96,7 @@ func stopCommands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, @@ -149,7 +150,7 @@ func generateDumpCommands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, @@ -227,7 +228,7 @@ func generateEncodingCommands(globalParams *command.GlobalParams) []*cobra.Comma fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, @@ -294,7 +295,7 @@ func diffCommands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, diff --git a/cmd/security-agent/subcommands/runtime/command.go b/cmd/security-agent/subcommands/runtime/command.go index 3b01f562c4c1e..5b9410b87456a 100644 --- a/cmd/security-agent/subcommands/runtime/command.go +++ b/cmd/security-agent/subcommands/runtime/command.go @@ -28,6 +28,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/aggregator/sender" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -93,7 +94,7 @@ func evalCommands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", false)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", false)}), core.Bundle, ) }, @@ -123,7 +124,7 @@ func commonCheckPoliciesCommands(globalParams *command.GlobalParams) []*cobra.Co fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", false)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", false)}), core.Bundle, ) }, @@ -144,7 +145,7 @@ func commonReloadPoliciesCommands(globalParams *command.GlobalParams) []*cobra.C fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, @@ -162,7 +163,7 @@ func selfTestCommands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, @@ -192,7 +193,7 @@ func downloadPolicyCommands(globalParams *command.GlobalParams) []*cobra.Command fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", false)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", false)}), core.Bundle, ) }, @@ -224,7 +225,7 @@ func processCacheCommands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, @@ -260,7 +261,7 @@ func networkNamespaceCommands(globalParams *command.GlobalParams) []*cobra.Comma fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, @@ -286,7 +287,7 @@ func discardersCommands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, diff --git a/cmd/security-agent/subcommands/runtime/deprecated_commands.go b/cmd/security-agent/subcommands/runtime/deprecated_commands.go index 8fad9fb83f0a6..bace10f974002 100644 --- a/cmd/security-agent/subcommands/runtime/deprecated_commands.go +++ b/cmd/security-agent/subcommands/runtime/deprecated_commands.go @@ -15,7 +15,7 @@ import ( "github.com/DataDog/datadog-agent/cmd/security-agent/flags" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -36,7 +36,7 @@ func checkPoliciesCommands(globalParams *command.GlobalParams) []*cobra.Command fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", false)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", false)}), core.Bundle, ) }, @@ -58,7 +58,7 @@ func reloadPoliciesCommands(globalParams *command.GlobalParams) []*cobra.Command fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, diff --git a/cmd/security-agent/subcommands/runtime/security_profile.go b/cmd/security-agent/subcommands/runtime/security_profile.go index 48dde0743a1e5..9fd8383ad66ee 100644 --- a/cmd/security-agent/subcommands/runtime/security_profile.go +++ b/cmd/security-agent/subcommands/runtime/security_profile.go @@ -19,6 +19,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" secagent "github.com/DataDog/datadog-agent/pkg/security/agent" "github.com/DataDog/datadog-agent/pkg/security/proto/api" @@ -62,7 +63,7 @@ func securityProfileShowCommands(globalParams *command.GlobalParams) []*cobra.Co fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, @@ -108,7 +109,7 @@ func listSecurityProfileCommands(globalParams *command.GlobalParams) []*cobra.Co fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, @@ -208,7 +209,7 @@ func saveSecurityProfileCommands(globalParams *command.GlobalParams) []*cobra.Co fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "info", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "info", true)}), core.Bundle, ) }, diff --git a/cmd/security-agent/subcommands/start/command.go b/cmd/security-agent/subcommands/start/command.go index 826c5810ee613..c96dfd7574c38 100644 --- a/cmd/security-agent/subcommands/start/command.go +++ b/cmd/security-agent/subcommands/start/command.go @@ -30,6 +30,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" @@ -83,7 +84,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { ConfigParams: config.NewSecurityAgentParams(params.ConfigFilePaths), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.SysProbeConfFilePath)), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForDaemon(command.LoggerName, "security_agent.log_file", pkgconfig.DefaultSecurityAgentLogFile), + LogParams: logimpl.ForDaemon(command.LoggerName, "security_agent.log_file", pkgconfig.DefaultSecurityAgentLogFile), }), core.Bundle, dogstatsd.ClientBundle, diff --git a/cmd/security-agent/subcommands/status/command.go b/cmd/security-agent/subcommands/status/command.go index e31c9875c9a83..814b1b1bdf42b 100644 --- a/cmd/security-agent/subcommands/status/command.go +++ b/cmd/security-agent/subcommands/status/command.go @@ -19,6 +19,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/api/util" "github.com/DataDog/datadog-agent/pkg/status/render" @@ -48,7 +49,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), SecretParams: secrets.NewEnabledParams(), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) }, diff --git a/cmd/security-agent/subcommands/version/command.go b/cmd/security-agent/subcommands/version/command.go index 670a10ad2af7b..34b916d71c53e 100644 --- a/cmd/security-agent/subcommands/version/command.go +++ b/cmd/security-agent/subcommands/version/command.go @@ -17,6 +17,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/pkg/serializer" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -33,7 +34,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { return fxutil.OneShot(displayVersion, fx.Supply(core.BundleParams{ ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), - LogParams: log.ForOneShot(command.LoggerName, "off", true)}), + LogParams: logimpl.ForOneShot(command.LoggerName, "off", true)}), core.Bundle, ) }, diff --git a/cmd/serverless-init/metric/metric_test.go b/cmd/serverless-init/metric/metric_test.go index b449a40f67feb..a5acbfb47b224 100644 --- a/cmd/serverless-init/metric/metric_test.go +++ b/cmd/serverless-init/metric/metric_test.go @@ -12,12 +12,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/util/fxutil" ) func TestAdd(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) timestamp := time.Now() add("a.super.metric", []string{"taga:valuea", "tagb:valueb"}, timestamp, demux) @@ -33,7 +34,7 @@ func TestAdd(t *testing.T) { } func TestAddColdStartMetric(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) timestamp := time.Now() AddColdStartMetric("gcp.run", []string{"taga:valuea", "tagb:valueb"}, timestamp, demux) @@ -48,7 +49,7 @@ func TestAddColdStartMetric(t *testing.T) { } func TestAddShutdownMetric(t *testing.T) { - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(log, time.Hour) timestamp := time.Now() AddShutdownMetric("gcp.run", []string{"taga:valuea", "tagb:valueb"}, timestamp, demux) diff --git a/cmd/system-probe/subcommands/config/command.go b/cmd/system-probe/subcommands/config/command.go index 4336b21bfbd23..d8cbccf957461 100644 --- a/cmd/system-probe/subcommands/config/command.go +++ b/cmd/system-probe/subcommands/config/command.go @@ -16,7 +16,7 @@ import ( "github.com/DataDog/datadog-agent/cmd/system-probe/command" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" "github.com/DataDog/datadog-agent/pkg/config/settings" @@ -47,7 +47,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewAgentParams("", config.WithConfigMissingOK(true)), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.ConfFilePath)), - LogParams: log.ForOneShot("SYS-PROBE", "off", true), + LogParams: logimpl.ForOneShot("SYS-PROBE", "off", true), }), // no need to provide sysprobe logger since ForOneShot ignores config values core.Bundle, diff --git a/cmd/system-probe/subcommands/debug/command.go b/cmd/system-probe/subcommands/debug/command.go index f7c0af46d7a1b..a51b360ab5808 100644 --- a/cmd/system-probe/subcommands/debug/command.go +++ b/cmd/system-probe/subcommands/debug/command.go @@ -17,7 +17,7 @@ import ( "github.com/DataDog/datadog-agent/cmd/system-probe/command" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" "github.com/DataDog/datadog-agent/pkg/api/util" @@ -49,7 +49,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewAgentParams("", config.WithConfigMissingOK(true)), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.ConfFilePath)), - LogParams: log.ForOneShot("SYS-PROBE", "off", false), + LogParams: logimpl.ForOneShot("SYS-PROBE", "off", false), }), // no need to provide sysprobe logger since ForOneShot ignores config values core.Bundle, diff --git a/cmd/system-probe/subcommands/modrestart/command.go b/cmd/system-probe/subcommands/modrestart/command.go index a7b6a4f53bf11..e9156bf7e968d 100644 --- a/cmd/system-probe/subcommands/modrestart/command.go +++ b/cmd/system-probe/subcommands/modrestart/command.go @@ -16,7 +16,7 @@ import ( "github.com/DataDog/datadog-agent/cmd/system-probe/command" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -47,7 +47,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(core.BundleParams{ ConfigParams: config.NewAgentParams("", config.WithConfigMissingOK(true)), SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.ConfFilePath)), - LogParams: log.ForOneShot("SYS-PROBE", "off", false), + LogParams: logimpl.ForOneShot("SYS-PROBE", "off", false), }), // no need to provide sysprobe logger since ForOneShot ignores config values core.Bundle, diff --git a/cmd/system-probe/subcommands/run/command.go b/cmd/system-probe/subcommands/run/command.go index f288aa756c310..b751ce8271386 100644 --- a/cmd/system-probe/subcommands/run/command.go +++ b/cmd/system-probe/subcommands/run/command.go @@ -29,6 +29,7 @@ import ( "github.com/DataDog/datadog-agent/cmd/system-probe/utils" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig" "github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl" "github.com/DataDog/datadog-agent/comp/core/telemetry" @@ -72,14 +73,14 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Supply(cliParams), fx.Supply(config.NewAgentParams("", config.WithConfigMissingOK(true))), fx.Supply(sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.ConfFilePath))), - fx.Supply(log.ForDaemon("SYS-PROBE", "log_file", common.DefaultLogFile)), + fx.Supply(logimpl.ForDaemon("SYS-PROBE", "log_file", common.DefaultLogFile)), config.Module, telemetry.Module, sysprobeconfigimpl.Module, rcclient.Module, // use system-probe config instead of agent config for logging - fx.Provide(func(lc fx.Lifecycle, params log.Params, sysprobeconfig sysprobeconfig.Component) (log.Component, error) { - return log.NewLogger(lc, params, sysprobeconfig) + fx.Provide(func(lc fx.Lifecycle, params logimpl.Params, sysprobeconfig sysprobeconfig.Component) (log.Component, error) { + return logimpl.NewLogger(lc, params, sysprobeconfig) }), ) }, @@ -185,14 +186,14 @@ func StartSystemProbeWithDefaults(ctxChan <-chan context.Context) (<-chan error, // no config file path specification in this situation fx.Supply(config.NewAgentParams("", config.WithConfigMissingOK(true))), fx.Supply(sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(""))), - fx.Supply(log.ForDaemon("SYS-PROBE", "log_file", common.DefaultLogFile)), + fx.Supply(logimpl.ForDaemon("SYS-PROBE", "log_file", common.DefaultLogFile)), rcclient.Module, config.Module, telemetry.Module, sysprobeconfigimpl.Module, // use system-probe config instead of agent config for logging - fx.Provide(func(lc fx.Lifecycle, params log.Params, sysprobeconfig sysprobeconfig.Component) (log.Component, error) { - return log.NewLogger(lc, params, sysprobeconfig) + fx.Provide(func(lc fx.Lifecycle, params logimpl.Params, sysprobeconfig sysprobeconfig.Component) (log.Component, error) { + return logimpl.NewLogger(lc, params, sysprobeconfig) }), ) // notify caller that fx.OneShot is done diff --git a/cmd/systray/command/command.go b/cmd/systray/command/command.go index e6bffccf8cb4d..d16de39c257dc 100644 --- a/cmd/systray/command/command.go +++ b/cmd/systray/command/command.go @@ -23,7 +23,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/flare" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/systray/systray" "github.com/DataDog/datadog-agent/comp/systray/systray/systrayimpl" "github.com/DataDog/datadog-agent/pkg/util/fxutil" @@ -63,11 +63,11 @@ func MakeCommand() *cobra.Command { } // log params - var logParams log.Params + var logParams logimpl.Params if subsystem == "windows" { - logParams = log.ForDaemon("TRAY", "system_tray.log_file", logFilePath) + logParams = logimpl.ForDaemon("TRAY", "system_tray.log_file", logFilePath) } else if subsystem == "console" { - logParams = log.ForOneShot("TRAY", "info", true) + logParams = logimpl.ForOneShot("TRAY", "info", true) } // root command diff --git a/cmd/trace-agent/subcommands/info/command.go b/cmd/trace-agent/subcommands/info/command.go index 085c0f5f80022..91efe1ac43cbe 100644 --- a/cmd/trace-agent/subcommands/info/command.go +++ b/cmd/trace-agent/subcommands/info/command.go @@ -43,7 +43,7 @@ func runTraceAgentInfoFct(params *subcommands.GlobalParams, fct interface{}) err coreconfig.Module, secretsimpl.Module, // TODO: (component) - // fx.Supply(log.ForOneShot(params.LoggerName, "off", true)), + // fx.Supply(logimpl.ForOneShot(params.LoggerName, "off", true)), // log.Module, ) } diff --git a/cmd/trace-agent/subcommands/run/command.go b/cmd/trace-agent/subcommands/run/command.go index 6ce9a9c7b1e0a..c09baa30e913b 100644 --- a/cmd/trace-agent/subcommands/run/command.go +++ b/cmd/trace-agent/subcommands/run/command.go @@ -14,7 +14,7 @@ import ( "github.com/DataDog/datadog-agent/cmd/agent/common" "github.com/DataDog/datadog-agent/cmd/trace-agent/subcommands" coreconfig "github.com/DataDog/datadog-agent/comp/core/config" - corelog "github.com/DataDog/datadog-agent/comp/core/log" + corelogimpl "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/secrets" "github.com/DataDog/datadog-agent/comp/core/secrets/secretsimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" @@ -68,10 +68,10 @@ func runFx(ctx context.Context, cliParams *RunParams, defaultConfPath string) er secretsimpl.Module, fx.Supply(secrets.NewEnabledParams()), coreconfig.Module, - fx.Provide(func() corelog.Params { - return corelog.ForDaemon("TRACE", "apm_config.log_file", config.DefaultLogFilePath) + fx.Provide(func() corelogimpl.Params { + return corelogimpl.ForDaemon("TRACE", "apm_config.log_file", config.DefaultLogFilePath) }), - corelog.TraceModule, + corelogimpl.TraceModule, // setup workloadmeta collectors.GetCatalog(), fx.Supply(workloadmeta.Params{ From 2e05b6b319a8f7ed3dfd4bbfcf2d6e12f2ad608a Mon Sep 17 00:00:00 2001 From: Olivier G Date: Thu, 30 Nov 2023 12:48:34 +0100 Subject: [PATCH 4/7] Fix Windows / Linux linter issue --- comp/metadata/resources/resourcesimpl/resources_test.go | 1 + pkg/collector/corechecks/sbom/processor_test.go | 1 + pkg/logs/launchers/container/tailerfactory/file_test.go | 1 + .../containers/metrics/containerd/collector_windows_test.go | 1 + pkg/util/containers/metrics/docker/collector_test.go | 1 + pkg/util/trivy/cache_test.go | 1 + test/integration/corechecks/docker/main_test.go | 6 +++--- 7 files changed, 9 insertions(+), 3 deletions(-) diff --git a/comp/metadata/resources/resourcesimpl/resources_test.go b/comp/metadata/resources/resourcesimpl/resources_test.go index da94bb752a366..ee0eab71c2eb3 100644 --- a/comp/metadata/resources/resourcesimpl/resources_test.go +++ b/comp/metadata/resources/resourcesimpl/resources_test.go @@ -21,6 +21,7 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" configUtils "github.com/DataDog/datadog-agent/pkg/config/utils" "github.com/DataDog/datadog-agent/pkg/serializer" "github.com/DataDog/datadog-agent/pkg/util/fxutil" diff --git a/pkg/collector/corechecks/sbom/processor_test.go b/pkg/collector/corechecks/sbom/processor_test.go index f6dedde1616e4..6c9618688edd7 100644 --- a/pkg/collector/corechecks/sbom/processor_test.go +++ b/pkg/collector/corechecks/sbom/processor_test.go @@ -25,6 +25,7 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" configcomp "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" "github.com/DataDog/datadog-agent/pkg/config" diff --git a/pkg/logs/launchers/container/tailerfactory/file_test.go b/pkg/logs/launchers/container/tailerfactory/file_test.go index 0f69b234cf8a9..64d3c7d548449 100644 --- a/pkg/logs/launchers/container/tailerfactory/file_test.go +++ b/pkg/logs/launchers/container/tailerfactory/file_test.go @@ -18,6 +18,7 @@ import ( "go.uber.org/fx" compConfig "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/comp/logs/agent/config" coreConfig "github.com/DataDog/datadog-agent/pkg/config" diff --git a/pkg/util/containers/metrics/containerd/collector_windows_test.go b/pkg/util/containers/metrics/containerd/collector_windows_test.go index 4609b2fcf7854..07bc9b872f646 100644 --- a/pkg/util/containers/metrics/containerd/collector_windows_test.go +++ b/pkg/util/containers/metrics/containerd/collector_windows_test.go @@ -14,6 +14,7 @@ import ( "github.com/opencontainers/runtime-spec/specs-go" "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/util/containers/metrics/provider" "github.com/DataDog/datadog-agent/pkg/util/fxutil" diff --git a/pkg/util/containers/metrics/docker/collector_test.go b/pkg/util/containers/metrics/docker/collector_test.go index e94238ee38d05..daa800344c9f0 100644 --- a/pkg/util/containers/metrics/docker/collector_test.go +++ b/pkg/util/containers/metrics/docker/collector_test.go @@ -18,6 +18,7 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors" "github.com/DataDog/datadog-agent/pkg/util/containers/metrics/provider" diff --git a/pkg/util/trivy/cache_test.go b/pkg/util/trivy/cache_test.go index 7a422123f1cc1..944559152e018 100644 --- a/pkg/util/trivy/cache_test.go +++ b/pkg/util/trivy/cache_test.go @@ -15,6 +15,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/util/fxutil" diff --git a/test/integration/corechecks/docker/main_test.go b/test/integration/corechecks/docker/main_test.go index b25f5c0b44ebe..bccb06e7f9af1 100644 --- a/test/integration/corechecks/docker/main_test.go +++ b/test/integration/corechecks/docker/main_test.go @@ -17,7 +17,7 @@ import ( "go.uber.org/fx" compcfg "github.com/DataDog/datadog-agent/comp/core/config" - complog "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" @@ -117,8 +117,8 @@ func setup() error { fx.Supply(compcfg.NewAgentParams( "", compcfg.WithConfigMissingOK(true))), compcfg.Module, - fx.Supply(complogimpl.ForOneShot("TEST", "info", false)), - complog.Module, + fx.Supply(logimpl.ForOneShot("TEST", "info", false)), + logimpl.Module, fx.Supply(workloadmeta.NewParams()), collectors.GetCatalog(), workloadmeta.Module, From 0c140112731d8572e2d8d72b5b631fc71eb51418 Mon Sep 17 00:00:00 2001 From: Olivier G Date: Thu, 30 Nov 2023 15:52:42 +0100 Subject: [PATCH 5/7] Fix linux build --- pkg/util/containers/metrics/containerd/collector_linux_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/util/containers/metrics/containerd/collector_linux_test.go b/pkg/util/containers/metrics/containerd/collector_linux_test.go index 58114de085349..bf5dff4c8f7e7 100644 --- a/pkg/util/containers/metrics/containerd/collector_linux_test.go +++ b/pkg/util/containers/metrics/containerd/collector_linux_test.go @@ -25,6 +25,7 @@ import ( "google.golang.org/protobuf/types/known/anypb" "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/core/workloadmeta" "github.com/DataDog/datadog-agent/pkg/util/containers/metrics/provider" "github.com/DataDog/datadog-agent/pkg/util/fxutil" From cf327e436924f42ad7d78b35a33a5ef569ec86c9 Mon Sep 17 00:00:00 2001 From: Olivier G Date: Fri, 1 Dec 2023 12:52:14 +0100 Subject: [PATCH 6/7] Fix conflicts --- pkg/aggregator/aggregator_test.go | 3 ++- pkg/aggregator/demultiplexer_agent_test.go | 4 ++-- pkg/aggregator/demultiplexer_test.go | 4 ++-- pkg/collector/corechecks/snmp/snmp_test.go | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/aggregator/aggregator_test.go b/pkg/aggregator/aggregator_test.go index 6ee0603ccbf9e..c05ac23a3fb4f 100644 --- a/pkg/aggregator/aggregator_test.go +++ b/pkg/aggregator/aggregator_test.go @@ -18,6 +18,7 @@ import ( // 3p "github.com/DataDog/datadog-agent/comp/core/config" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" pkgconfig "github.com/DataDog/datadog-agent/pkg/config" @@ -684,7 +685,7 @@ type aggregatorDeps struct { } func createAggrDeps(t *testing.T) aggregatorDeps { - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) opts := demuxTestOptions() return aggregatorDeps{ diff --git a/pkg/aggregator/demultiplexer_agent_test.go b/pkg/aggregator/demultiplexer_agent_test.go index 99ba046de6d43..ccb2795cf652a 100644 --- a/pkg/aggregator/demultiplexer_agent_test.go +++ b/pkg/aggregator/demultiplexer_agent_test.go @@ -55,7 +55,7 @@ func TestDemuxNoAggOptionDisabled(t *testing.T) { require := require.New(t) opts := demuxTestOptions() - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{}) demux := initAgentDemultiplexer(log, NewForwarderTest(log), &orchestratorForwarder, opts, "") @@ -76,7 +76,7 @@ func TestDemuxNoAggOptionEnabled(t *testing.T) { opts := demuxTestOptions() mockSerializer := &MockSerializerIterableSerie{} opts.EnableNoAggregationPipeline = true - log := fxutil.Test[log.Component](t, log.MockModule) + log := fxutil.Test[log.Component](t, logimpl.MockModule) orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{}) demux := initAgentDemultiplexer(log, NewForwarderTest(log), &orchestratorForwarder, opts, "") demux.statsd.noAggStreamWorker.serializer = mockSerializer // the no agg pipeline will use our mocked serializer diff --git a/pkg/aggregator/demultiplexer_test.go b/pkg/aggregator/demultiplexer_test.go index abf24aa4c8fd1..70cf939098559 100644 --- a/pkg/aggregator/demultiplexer_test.go +++ b/pkg/aggregator/demultiplexer_test.go @@ -12,7 +12,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/config" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" orchestratorForwarder "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator" orchestratorForwarderImpl "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl" @@ -290,7 +290,7 @@ type internalDemutiplexerDeps struct { } func createDemuxDepsWithOrchestratorFwd(t *testing.T, opts AgentDemultiplexerOptions, params orchestratorForwarderImpl.Params) aggregatorDeps { - modules := fx.Options(defaultforwarder.MockModule, config.MockModule, log.MockModule, orchestratorForwarderImpl.Module, fx.Supply(params)) + modules := fx.Options(defaultforwarder.MockModule, config.MockModule, logimpl.MockModule, orchestratorForwarderImpl.Module, fx.Supply(params)) deps := fxutil.Test[internalDemutiplexerDeps](t, modules) return aggregatorDeps{ diff --git a/pkg/collector/corechecks/snmp/snmp_test.go b/pkg/collector/corechecks/snmp/snmp_test.go index b677a304596da..edde219021e20 100644 --- a/pkg/collector/corechecks/snmp/snmp_test.go +++ b/pkg/collector/corechecks/snmp/snmp_test.go @@ -19,7 +19,7 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/comp/aggregator/demultiplexer" - "github.com/DataDog/datadog-agent/comp/core/log" + "github.com/DataDog/datadog-agent/comp/core/log/logimpl" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/netflow/config" "github.com/DataDog/datadog-agent/pkg/aggregator" @@ -55,7 +55,7 @@ type deps struct { } func createDeps(t *testing.T) deps { - return fxutil.Test[deps](t, defaultforwarder.MockModule, config.MockModule, log.MockModule) + return fxutil.Test[deps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) } func Test_Run_simpleCase(t *testing.T) { From 64fd185336fb4abdb515e480d993471b48bc54f4 Mon Sep 17 00:00:00 2001 From: Olivier G Date: Thu, 7 Dec 2023 17:59:19 +0100 Subject: [PATCH 7/7] fix code conflict issue --- pkg/collector/corechecks/snmp/snmp_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/collector/corechecks/snmp/snmp_test.go b/pkg/collector/corechecks/snmp/snmp_test.go index 435a5d3d77e30..28091939af9fe 100644 --- a/pkg/collector/corechecks/snmp/snmp_test.go +++ b/pkg/collector/corechecks/snmp/snmp_test.go @@ -9,10 +9,11 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/DataDog/datadog-agent/pkg/collector/corechecks/snmp/internal/report" "testing" "time" + "github.com/DataDog/datadog-agent/pkg/collector/corechecks/snmp/internal/report" + "github.com/gosnmp/gosnmp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -57,7 +58,7 @@ type deps struct { } func createDeps(t *testing.T) deps { - return fxutil.Test[deps](t, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) + return fxutil.Test[deps](t, demultiplexer.MockModule, defaultforwarder.MockModule, config.MockModule, logimpl.MockModule) } func Test_Run_simpleCase(t *testing.T) {