diff --git a/cmd/agent/subcommands/diagnose/command.go b/cmd/agent/subcommands/diagnose/command.go index 8ed4bf53699e8..d2ab52827e8c1 100644 --- a/cmd/agent/subcommands/diagnose/command.go +++ b/cmd/agent/subcommands/diagnose/command.go @@ -28,6 +28,7 @@ import ( wmcatalog "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/catalog" workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def" workloadmetafx "github.com/DataDog/datadog-agent/comp/core/workloadmeta/fx" + haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" "github.com/DataDog/datadog-agent/pkg/api/util" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" @@ -106,6 +107,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { autodiscoveryimpl.Module(), compressionimpl.Module(), diagnosesendermanagerimpl.Module(), + haagentfx.Module(), ) }, } diff --git a/cmd/agent/subcommands/flare/command.go b/cmd/agent/subcommands/flare/command.go index ffc7459b64078..7f13516cdd8d4 100644 --- a/cmd/agent/subcommands/flare/command.go +++ b/cmd/agent/subcommands/flare/command.go @@ -43,6 +43,7 @@ import ( wmcatalog "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/catalog" workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def" workloadmetafx "github.com/DataDog/datadog-agent/comp/core/workloadmeta/fx" + haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx" "github.com/DataDog/datadog-agent/comp/metadata/host/hostimpl" "github.com/DataDog/datadog-agent/comp/metadata/inventoryagent/inventoryagentimpl" "github.com/DataDog/datadog-agent/comp/metadata/inventoryhost/inventoryhostimpl" @@ -144,6 +145,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { return nil }), core.Bundle(), + haagentfx.Module(), ) }, } diff --git a/cmd/agent/subcommands/jmx/command.go b/cmd/agent/subcommands/jmx/command.go index d7021dd32720b..c7df8718fa799 100644 --- a/cmd/agent/subcommands/jmx/command.go +++ b/cmd/agent/subcommands/jmx/command.go @@ -53,6 +53,7 @@ import ( "github.com/DataDog/datadog-agent/comp/dogstatsd/pidmap" replay "github.com/DataDog/datadog-agent/comp/dogstatsd/replay/def" dogstatsdServer "github.com/DataDog/datadog-agent/comp/dogstatsd/server" + haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx" "github.com/DataDog/datadog-agent/comp/remote-config/rcservice" "github.com/DataDog/datadog-agent/comp/remote-config/rcservicemrf" "github.com/DataDog/datadog-agent/pkg/aggregator/sender" @@ -167,6 +168,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { proccontainers.InitSharedContainerProvider(wmeta, tagger) }), fx.Provide(func() remoteagentregistry.Component { return nil }), + haagentfx.Module(), ) } diff --git a/cmd/agent/subcommands/snmp/command.go b/cmd/agent/subcommands/snmp/command.go index 77abfb7c29961..5ab675e9d7a3e 100644 --- a/cmd/agent/subcommands/snmp/command.go +++ b/cmd/agent/subcommands/snmp/command.go @@ -26,6 +26,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatformreceiver/eventplatformreceiverimpl" "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl" + haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" snmpscan "github.com/DataDog/datadog-agent/comp/snmpscan/def" snmpscanfx "github.com/DataDog/datadog-agent/comp/snmpscan/fx" @@ -100,6 +101,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { nooptagger.Module(), compressionimpl.Module(), eventplatformreceiverimpl.Module(), + haagentfx.Module(), ) if err != nil { var ue configErr @@ -163,6 +165,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { nooptagger.Module(), compressionimpl.Module(), snmpscanfx.Module(), + haagentfx.Module(), ) if err != nil { var ue configErr diff --git a/cmd/cluster-agent-cloudfoundry/subcommands/run/command.go b/cmd/cluster-agent-cloudfoundry/subcommands/run/command.go index 305b872133d7d..de5c2a6251426 100644 --- a/cmd/cluster-agent-cloudfoundry/subcommands/run/command.go +++ b/cmd/cluster-agent-cloudfoundry/subcommands/run/command.go @@ -49,6 +49,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatformreceiver/eventplatformreceiverimpl" orchestratorForwarderImpl "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl" + haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx" integrations "github.com/DataDog/datadog-agent/comp/logs/integrations/def" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" "github.com/DataDog/datadog-agent/pkg/clusteragent" @@ -126,6 +127,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Invoke(func(wmeta workloadmeta.Component, tagger tagger.Component) { proccontainers.InitSharedContainerProvider(wmeta, tagger) }), + haagentfx.Module(), ) }, } diff --git a/cmd/cluster-agent/subcommands/start/command.go b/cmd/cluster-agent/subcommands/start/command.go index c4cd5d83276b9..e474997485de5 100644 --- a/cmd/cluster-agent/subcommands/start/command.go +++ b/cmd/cluster-agent/subcommands/start/command.go @@ -60,6 +60,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatformreceiver/eventplatformreceiverimpl" orchestratorForwarderImpl "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl" + haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx" integrations "github.com/DataDog/datadog-agent/comp/logs/integrations/def" rccomp "github.com/DataDog/datadog-agent/comp/remote-config/rcservice" "github.com/DataDog/datadog-agent/comp/remote-config/rcservice/rcserviceimpl" @@ -203,6 +204,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { fx.Invoke(func(wmeta workloadmeta.Component, tagger tagger.Component) { proccontainers.InitSharedContainerProvider(wmeta, tagger) }), + haagentfx.Module(), ) }, } diff --git a/cmd/dogstatsd/subcommands/start/command.go b/cmd/dogstatsd/subcommands/start/command.go index cd7dea61251b7..1b67382c861a3 100644 --- a/cmd/dogstatsd/subcommands/start/command.go +++ b/cmd/dogstatsd/subcommands/start/command.go @@ -43,6 +43,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatformreceiver/eventplatformreceiverimpl" orchestratorForwarderImpl "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl" + haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx" "github.com/DataDog/datadog-agent/comp/metadata/host" "github.com/DataDog/datadog-agent/comp/metadata/host/hostimpl" "github.com/DataDog/datadog-agent/comp/metadata/inventoryagent" @@ -173,6 +174,7 @@ func RunDogstatsdFct(cliParams *CLIParams, defaultConfPath string, defaultLogFil } }), healthprobefx.Module(), + haagentfx.Module(), ) } diff --git a/cmd/systray/command/command.go b/cmd/systray/command/command.go index b91fa3eac86df..df2415c7164ef 100644 --- a/cmd/systray/command/command.go +++ b/cmd/systray/command/command.go @@ -27,6 +27,7 @@ import ( log "github.com/DataDog/datadog-agent/comp/core/log/def" nooptagger "github.com/DataDog/datadog-agent/comp/core/tagger/fx-noop" workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def" + haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx" "github.com/DataDog/datadog-agent/comp/metadata/inventoryagent/inventoryagentimpl" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" "github.com/DataDog/datadog-agent/comp/systray/systray" @@ -125,6 +126,7 @@ func MakeCommand() *cobra.Command { systrayimpl.Module(), // require the systray component, causing it to start fx.Invoke(func(_ systray.Component) {}), + haagentfx.Module(), ) }, } diff --git a/comp/aggregator/bundle_test.go b/comp/aggregator/bundle_test.go index 3a426385bccef..9b31c53698d21 100644 --- a/comp/aggregator/bundle_test.go +++ b/comp/aggregator/bundle_test.go @@ -14,6 +14,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" orchestratorForwarderImpl "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl" + haagentmock "github.com/DataDog/datadog-agent/comp/haagent/mock" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" "github.com/DataDog/datadog-agent/pkg/util/fxutil" ) @@ -26,5 +27,6 @@ func TestBundleDependencies(t *testing.T) { orchestratorForwarderImpl.MockModule(), eventplatformimpl.MockModule(), nooptagger.Module(), + haagentmock.Module(), ) } diff --git a/comp/aggregator/demultiplexer/demultiplexerimpl/demultiplexer.go b/comp/aggregator/demultiplexer/demultiplexerimpl/demultiplexer.go index c50c6528029a8..80a4817d42804 100644 --- a/comp/aggregator/demultiplexer/demultiplexerimpl/demultiplexer.go +++ b/comp/aggregator/demultiplexer/demultiplexerimpl/demultiplexer.go @@ -20,6 +20,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform" orchestratorforwarder "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator" + haagent "github.com/DataDog/datadog-agent/comp/haagent/def" "github.com/DataDog/datadog-agent/comp/serializer/compression" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/aggregator/sender" @@ -42,6 +43,7 @@ type dependencies struct { SharedForwarder defaultforwarder.Component OrchestratorForwarder orchestratorforwarder.Component EventPlatformForwarder eventplatform.Component + HaAgent haagent.Component Compressor compression.Component Tagger tagger.Component @@ -86,6 +88,7 @@ func newDemultiplexer(deps dependencies) (provides, error) { deps.OrchestratorForwarder, options, deps.EventPlatformForwarder, + deps.HaAgent, deps.Compressor, deps.Tagger, hostnameDetected, diff --git a/comp/aggregator/demultiplexer/demultiplexerimpl/demultiplexer_mock.go b/comp/aggregator/demultiplexer/demultiplexerimpl/demultiplexer_mock.go index f7dc85d7beb18..eb8cfb684bc75 100644 --- a/comp/aggregator/demultiplexer/demultiplexerimpl/demultiplexer_mock.go +++ b/comp/aggregator/demultiplexer/demultiplexerimpl/demultiplexer_mock.go @@ -15,6 +15,7 @@ import ( "github.com/DataDog/datadog-agent/comp/core/hostname" log "github.com/DataDog/datadog-agent/comp/core/log/def" "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" + haagentmock "github.com/DataDog/datadog-agent/comp/haagent/mock" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/aggregator/sender" @@ -76,6 +77,7 @@ func newMock(deps mockDependencies) MockProvides { Hostname: deps.Hostname, SharedForwarder: defaultforwarder.NoopForwarder{}, Compressor: compressionimpl.NewMockCompressor(), + HaAgent: haagentmock.NewMockHaAgent(), } instance := &mock{AgentDemultiplexer: aggregator.InitAndStartAgentDemultiplexerForTest(aggDeps, opts, "")} diff --git a/comp/aggregator/demultiplexer/demultiplexerimpl/status_test.go b/comp/aggregator/demultiplexer/demultiplexerimpl/status_test.go index e66c099ac36aa..e5c620f88db3c 100644 --- a/comp/aggregator/demultiplexer/demultiplexerimpl/status_test.go +++ b/comp/aggregator/demultiplexer/demultiplexerimpl/status_test.go @@ -20,6 +20,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl" + haagentmock "github.com/DataDog/datadog-agent/comp/haagent/mock" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" "github.com/DataDog/datadog-agent/pkg/util/fxutil" ) @@ -61,6 +62,7 @@ func TestStatusOutPut(t *testing.T) { core.MockBundle(), compressionimpl.MockModule(), defaultforwarder.MockModule(), + haagentmock.Module(), orchestratorimpl.MockModule(), eventplatformimpl.MockModule(), fx.Provide(func() tagger.Component { diff --git a/comp/aggregator/demultiplexer/demultiplexerimpl/test_agent_demultiplexer.go b/comp/aggregator/demultiplexer/demultiplexerimpl/test_agent_demultiplexer.go index 4ac27d7d64460..9e051328c961d 100644 --- a/comp/aggregator/demultiplexer/demultiplexerimpl/test_agent_demultiplexer.go +++ b/comp/aggregator/demultiplexer/demultiplexerimpl/test_agent_demultiplexer.go @@ -18,6 +18,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" + haagentmock "github.com/DataDog/datadog-agent/comp/haagent/mock" "github.com/DataDog/datadog-agent/comp/serializer/compression" "github.com/DataDog/datadog-agent/pkg/aggregator" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" @@ -185,6 +186,6 @@ func initTestAgentDemultiplexerWithFlushInterval(log log.Component, hostname hos sharedForwarder := defaultforwarder.NewDefaultForwarder(pkgconfigsetup.Datadog(), log, sharedForwarderOptions) orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{}) eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(hostname)) - demux := aggregator.InitAndStartAgentDemultiplexer(log, sharedForwarder, &orchestratorForwarder, opts, eventPlatformForwarder, compressor, noopimpl.NewComponent(), "hostname") + demux := aggregator.InitAndStartAgentDemultiplexer(log, sharedForwarder, &orchestratorForwarder, opts, eventPlatformForwarder, haagentmock.NewMockHaAgent(), compressor, noopimpl.NewComponent(), "hostname") return NewTestAgentDemultiplexer(demux) } diff --git a/comp/aggregator/diagnosesendermanager/diagnosesendermanagerimpl/sendermanager.go b/comp/aggregator/diagnosesendermanager/diagnosesendermanagerimpl/sendermanager.go index 73de2ac99cca7..b48e237937c57 100644 --- a/comp/aggregator/diagnosesendermanager/diagnosesendermanagerimpl/sendermanager.go +++ b/comp/aggregator/diagnosesendermanager/diagnosesendermanagerimpl/sendermanager.go @@ -19,6 +19,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" + haagent "github.com/DataDog/datadog-agent/comp/haagent/def" "github.com/DataDog/datadog-agent/comp/serializer/compression" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/aggregator/sender" @@ -39,6 +40,7 @@ type dependencies struct { Hostname hostname.Component Compressor compression.Component Tagger tagger.Component + HaAgent haagent.Component } type diagnoseSenderManager struct { @@ -69,6 +71,7 @@ func (sender *diagnoseSenderManager) LazyGetSenderManager() (sender.SenderManage log := sender.deps.Log config := sender.deps.Config + haAgent := sender.deps.HaAgent forwarder := defaultforwarder.NewDefaultForwarder(config, log, defaultforwarder.NewOptions(config, log, nil)) orchestratorForwarder := optional.NewOptionPtr[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{}) eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(sender.deps.Hostname)) @@ -78,6 +81,7 @@ func (sender *diagnoseSenderManager) LazyGetSenderManager() (sender.SenderManage orchestratorForwarder, opts, eventPlatformForwarder, + haAgent, sender.deps.Compressor, sender.deps.Tagger, hostnameDetected) diff --git a/comp/haagent/mock/mock.go b/comp/haagent/mock/mock.go index 6ee0c733361f7..52142737704c9 100644 --- a/comp/haagent/mock/mock.go +++ b/comp/haagent/mock/mock.go @@ -9,37 +9,60 @@ package mock import ( - "testing" + "go.uber.org/fx" log "github.com/DataDog/datadog-agent/comp/core/log/def" haagent "github.com/DataDog/datadog-agent/comp/haagent/def" + "github.com/DataDog/datadog-agent/pkg/util/fxutil" ) -type mock struct { +type mockHaAgent struct { Logger log.Component + + group string + enabled bool +} + +func (m *mockHaAgent) GetGroup() string { + return m.group +} + +func (m *mockHaAgent) Enabled() bool { + return m.enabled } -func (m *mock) GetGroup() string { - return "mockGroup01" +func (m *mockHaAgent) SetLeader(_ string) { } -func (m *mock) Enabled() bool { - return true +func (m *mockHaAgent) IsLeader() bool { return false } + +func (m *mockHaAgent) SetGroup(group string) { + m.group = group } -func (m *mock) SetLeader(_ string) { +func (m *mockHaAgent) SetEnabled(enabled bool) { + m.enabled = enabled } -func (m *mock) IsLeader() bool { return false } +// Component is the component type. +type Component interface { + haagent.Component -// Provides that defines the output of mocked snmpscan component -type Provides struct { - comp haagent.Component + SetGroup(string) + SetEnabled(bool) } -// Mock returns a mock for haagent component. -func Mock(_ *testing.T) Provides { - return Provides{ - comp: &mock{}, +// NewMockHaAgent returns a new Mock +func NewMockHaAgent() haagent.Component { + return &mockHaAgent{ + enabled: false, + group: "group01", } } + +// Module defines the fx options for the mock component. +func Module() fxutil.Module { + return fxutil.Component( + fx.Provide(NewMockHaAgent), + ) +} diff --git a/pkg/aggregator/aggregator.go b/pkg/aggregator/aggregator.go index d42ac89d50e47..e8ac4fd425d13 100644 --- a/pkg/aggregator/aggregator.go +++ b/pkg/aggregator/aggregator.go @@ -16,6 +16,7 @@ import ( tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def" "github.com/DataDog/datadog-agent/comp/core/tagger/types" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform" + haagent "github.com/DataDog/datadog-agent/comp/haagent/def" "github.com/DataDog/datadog-agent/pkg/aggregator/internal/tags" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" "github.com/DataDog/datadog-agent/pkg/config/model" @@ -252,6 +253,7 @@ type BufferedAggregator struct { flushMutex sync.Mutex // to start multiple flushes in parallel serializer serializer.MetricSerializer eventPlatformForwarder eventplatform.Component + haAgent haagent.Component hostname string hostnameUpdate chan string hostnameUpdateDone chan struct{} // signals that the hostname update is finished @@ -283,7 +285,7 @@ func NewFlushAndSerializeInParallel(config model.Config) FlushAndSerializeInPara } // NewBufferedAggregator instantiates a BufferedAggregator -func NewBufferedAggregator(s serializer.MetricSerializer, eventPlatformForwarder eventplatform.Component, tagger tagger.Component, hostname string, flushInterval time.Duration) *BufferedAggregator { +func NewBufferedAggregator(s serializer.MetricSerializer, eventPlatformForwarder eventplatform.Component, haAgent haagent.Component, tagger tagger.Component, hostname string, flushInterval time.Duration) *BufferedAggregator { bufferSize := pkgconfigsetup.Datadog().GetInt("aggregator_buffer_size") agentName := flavor.GetFlavor() @@ -326,6 +328,7 @@ func NewBufferedAggregator(s serializer.MetricSerializer, eventPlatformForwarder flushInterval: flushInterval, serializer: s, eventPlatformForwarder: eventPlatformForwarder, + haAgent: haAgent, hostname: hostname, hostnameUpdate: make(chan string), hostnameUpdateDone: make(chan struct{}), @@ -861,6 +864,9 @@ func (agg *BufferedAggregator) tags(withVersion bool) []string { tags = append(tags, "package_version:"+version.AgentPackageVersion) } } + if agg.haAgent.Enabled() { + tags = append(tags, "agent_group:"+agg.haAgent.GetGroup()) + } // nil to empty string // This is expected by other components/tests if tags == nil { diff --git a/pkg/aggregator/aggregator_test.go b/pkg/aggregator/aggregator_test.go index 64c33496891c7..c08aff0278bb1 100644 --- a/pkg/aggregator/aggregator_test.go +++ b/pkg/aggregator/aggregator_test.go @@ -27,6 +27,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform" orchestratorforwarder "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator" + haagentmock "github.com/DataDog/datadog-agent/comp/haagent/mock" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" configmock "github.com/DataDog/datadog-agent/pkg/config/mock" @@ -146,7 +147,7 @@ func TestAddServiceCheckDefaultValues(t *testing.T) { s := &MockSerializerIterableSerie{} taggerComponent := taggerMock.SetupFakeTagger(t) - agg := NewBufferedAggregator(s, nil, taggerComponent, "resolved-hostname", DefaultFlushInterval) + agg := NewBufferedAggregator(s, nil, nil, taggerComponent, "resolved-hostname", DefaultFlushInterval) agg.addServiceCheck(servicecheck.ServiceCheck{ // leave Host and Ts fields blank @@ -179,7 +180,7 @@ func TestAddEventDefaultValues(t *testing.T) { s := &MockSerializerIterableSerie{} taggerComponent := taggerMock.SetupFakeTagger(t) - agg := NewBufferedAggregator(s, nil, taggerComponent, "resolved-hostname", DefaultFlushInterval) + agg := NewBufferedAggregator(s, nil, nil, taggerComponent, "resolved-hostname", DefaultFlushInterval) agg.addEvent(event.Event{ // only populate required fields @@ -229,7 +230,7 @@ func TestDefaultData(t *testing.T) { s := &MockSerializerIterableSerie{} taggerComponent := taggerMock.SetupFakeTagger(t) - agg := NewBufferedAggregator(s, nil, taggerComponent, "hostname", DefaultFlushInterval) + agg := NewBufferedAggregator(s, nil, haagentmock.NewMockHaAgent(), taggerComponent, "hostname", DefaultFlushInterval) start := time.Now() @@ -512,6 +513,7 @@ func TestTags(t *testing.T) { agentTags func(types.TagCardinality) ([]string, error) globalTags func(types.TagCardinality) ([]string, error) withVersion bool + haAgentEnabled bool want []string }{ { @@ -577,6 +579,16 @@ func TestTags(t *testing.T) { withVersion: true, want: []string{"container_name:agent", "version:" + version.AgentVersion, "kube_cluster_name:foo"}, }, + { + name: "tags disabled, without version, ha agent enabled", + hostname: "hostname", + tlmContainerTagsEnabled: false, + agentTags: func(types.TagCardinality) ([]string, error) { return nil, errors.New("disabled") }, + globalTags: func(types.TagCardinality) ([]string, error) { return nil, errors.New("disabled") }, + withVersion: false, + haAgentEnabled: true, + want: []string{"agent_group:group01"}, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -585,7 +597,10 @@ func TestTags(t *testing.T) { taggerComponent := taggerMock.SetupFakeTagger(t) - agg := NewBufferedAggregator(nil, nil, taggerComponent, tt.hostname, time.Second) + mockHaAgent := haagentmock.NewMockHaAgent().(haagentmock.Component) + mockHaAgent.SetEnabled(tt.haAgentEnabled) + + agg := NewBufferedAggregator(nil, nil, mockHaAgent, taggerComponent, tt.hostname, time.Second) agg.agentTags = tt.agentTags agg.globalTags = tt.globalTags assert.ElementsMatch(t, tt.want, agg.tags(tt.withVersion)) @@ -619,7 +634,7 @@ func TestAddDJMRecurrentSeries(t *testing.T) { s := &MockSerializerIterableSerie{} // NewBufferedAggregator with DJM enable will create a new recurrentSeries taggerComponent := taggerMock.SetupFakeTagger(t) - NewBufferedAggregator(s, nil, taggerComponent, "hostname", DefaultFlushInterval) + NewBufferedAggregator(s, nil, nil, taggerComponent, "hostname", DefaultFlushInterval) expectedRecurrentSeries := metrics.Series{&metrics.Serie{ Name: "datadog.djm.agent_host", @@ -728,7 +743,7 @@ type aggregatorDeps struct { } func createAggrDeps(t *testing.T) aggregatorDeps { - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule(), core.MockBundle(), compressionimpl.MockModule()) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule(), core.MockBundle(), compressionimpl.MockModule(), haagentmock.Module()) opts := demuxTestOptions() return aggregatorDeps{ diff --git a/pkg/aggregator/check_sampler_bench_test.go b/pkg/aggregator/check_sampler_bench_test.go index dbb6e8b57bf45..daac7d2c251f6 100644 --- a/pkg/aggregator/check_sampler_bench_test.go +++ b/pkg/aggregator/check_sampler_bench_test.go @@ -17,6 +17,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" + haagentmock "github.com/DataDog/datadog-agent/comp/haagent/mock" "github.com/DataDog/datadog-agent/comp/serializer/compression" //nolint:revive // TODO(AML) Fix revive linter @@ -51,7 +52,8 @@ func benchmarkAddBucket(bucketValue int64, b *testing.B) { sharedForwarder := forwarder.NewDefaultForwarder(pkgconfigsetup.Datadog(), deps.Log, forwarderOpts) orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{}) eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(deps.Hostname)) - demux := InitAndStartAgentDemultiplexer(deps.Log, sharedForwarder, &orchestratorForwarder, options, eventPlatformForwarder, deps.Compressor, taggerComponent, "hostname") + haAgent := haagentmock.NewMockHaAgent() + demux := InitAndStartAgentDemultiplexer(deps.Log, sharedForwarder, &orchestratorForwarder, options, eventPlatformForwarder, haAgent, deps.Compressor, taggerComponent, "hostname") defer demux.Stop(true) checkSampler := newCheckSampler(1, true, true, 1000, tags.NewStore(true, "bench"), checkid.ID("hello:world:1234"), taggerComponent) diff --git a/pkg/aggregator/demultiplexer_agent.go b/pkg/aggregator/demultiplexer_agent.go index a420537fccd25..36528b374b745 100644 --- a/pkg/aggregator/demultiplexer_agent.go +++ b/pkg/aggregator/demultiplexer_agent.go @@ -17,6 +17,7 @@ import ( forwarder "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform" orchestratorforwarder "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator" + haagent "github.com/DataDog/datadog-agent/comp/haagent/def" "github.com/DataDog/datadog-agent/comp/serializer/compression" "github.com/DataDog/datadog-agent/pkg/aggregator/internal/tags" "github.com/DataDog/datadog-agent/pkg/aggregator/sender" @@ -125,20 +126,21 @@ func InitAndStartAgentDemultiplexer( orchestratorForwarder orchestratorforwarder.Component, options AgentDemultiplexerOptions, eventPlatformForwarder eventplatform.Component, + haAgent haagent.Component, compressor compression.Component, tagger tagger.Component, hostname string) *AgentDemultiplexer { - demux := initAgentDemultiplexer(log, sharedForwarder, orchestratorForwarder, options, eventPlatformForwarder, compressor, tagger, hostname) + demux := initAgentDemultiplexer(log, sharedForwarder, orchestratorForwarder, options, eventPlatformForwarder, haAgent, compressor, tagger, hostname) go demux.run() return demux } -func initAgentDemultiplexer( - log log.Component, +func initAgentDemultiplexer(log log.Component, sharedForwarder forwarder.Forwarder, orchestratorForwarder orchestratorforwarder.Component, options AgentDemultiplexerOptions, eventPlatformForwarder eventplatform.Component, + haAgent haagent.Component, compressor compression.Component, tagger tagger.Component, hostname string) *AgentDemultiplexer { @@ -157,7 +159,7 @@ func initAgentDemultiplexer( // prepare the embedded aggregator // -- - agg := NewBufferedAggregator(sharedSerializer, eventPlatformForwarder, tagger, hostname, options.FlushInterval) + agg := NewBufferedAggregator(sharedSerializer, eventPlatformForwarder, haAgent, tagger, hostname, options.FlushInterval) // statsd samplers // --------------- diff --git a/pkg/aggregator/demultiplexer_agent_test.go b/pkg/aggregator/demultiplexer_agent_test.go index f2703abc6ec17..0d0d1af8a4ef8 100644 --- a/pkg/aggregator/demultiplexer_agent_test.go +++ b/pkg/aggregator/demultiplexer_agent_test.go @@ -23,6 +23,8 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" orchestratorforwarder "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator" "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl" + haagent "github.com/DataDog/datadog-agent/comp/haagent/def" + haagentmock "github.com/DataDog/datadog-agent/comp/haagent/mock" "github.com/DataDog/datadog-agent/comp/serializer/compression" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" "github.com/DataDog/datadog-agent/pkg/metrics" @@ -65,7 +67,7 @@ func TestDemuxNoAggOptionDisabled(t *testing.T) { opts := demuxTestOptions() deps := createDemultiplexerAgentTestDeps(t) - demux := initAgentDemultiplexer(deps.Log, NewForwarderTest(deps.Log), deps.OrchestratorFwd, opts, deps.EventPlatform, deps.Compressor, deps.Tagger, "") + demux := initAgentDemultiplexer(deps.Log, NewForwarderTest(deps.Log), deps.OrchestratorFwd, opts, deps.EventPlatform, deps.HaAgent, deps.Compressor, deps.Tagger, "") batch := testDemuxSamples(t) @@ -87,7 +89,7 @@ func TestDemuxNoAggOptionEnabled(t *testing.T) { mockSerializer.On("AreSketchesEnabled").Return(true) opts.EnableNoAggregationPipeline = true deps := createDemultiplexerAgentTestDeps(t) - demux := initAgentDemultiplexer(deps.Log, NewForwarderTest(deps.Log), deps.OrchestratorFwd, opts, deps.EventPlatform, deps.Compressor, deps.Tagger, "") + demux := initAgentDemultiplexer(deps.Log, NewForwarderTest(deps.Log), deps.OrchestratorFwd, opts, deps.EventPlatform, deps.HaAgent, deps.Compressor, deps.Tagger, "") demux.statsd.noAggStreamWorker.serializer = mockSerializer // the no agg pipeline will use our mocked serializer go demux.run() @@ -112,7 +114,7 @@ func TestDemuxNoAggOptionEnabled(t *testing.T) { func TestDemuxNoAggOptionIsDisabledByDefault(t *testing.T) { opts := demuxTestOptions() - deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule(), core.MockBundle(), compressionimpl.MockModule()) + deps := fxutil.Test[TestDeps](t, defaultforwarder.MockModule(), core.MockBundle(), compressionimpl.MockModule(), haagentmock.Module()) demux := InitAndStartAgentDemultiplexerForTest(deps, opts, "") require.False(t, demux.Options().EnableNoAggregationPipeline, "the no aggregation pipeline should be disabled by default") @@ -157,6 +159,7 @@ type DemultiplexerAgentTestDeps struct { EventPlatform eventplatform.Component Compressor compression.Component Tagger tagger.Component + HaAgent haagent.Component } func createDemultiplexerAgentTestDeps(t *testing.T) DemultiplexerAgentTestDeps { @@ -168,6 +171,7 @@ func createDemultiplexerAgentTestDeps(t *testing.T) DemultiplexerAgentTestDeps { core.MockBundle(), orchestratorimpl.MockModule(), eventplatformimpl.MockModule(), + haagentmock.Module(), compressionimpl.MockModule(), fx.Provide(func() tagger.Component { return taggerComponent }), ) diff --git a/pkg/aggregator/demultiplexer_mock.go b/pkg/aggregator/demultiplexer_mock.go index 917a788795957..c6511f7eb6890 100644 --- a/pkg/aggregator/demultiplexer_mock.go +++ b/pkg/aggregator/demultiplexer_mock.go @@ -16,6 +16,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" + haagent "github.com/DataDog/datadog-agent/comp/haagent/def" "github.com/DataDog/datadog-agent/comp/serializer/compression" "github.com/DataDog/datadog-agent/pkg/util/optional" ) @@ -27,11 +28,12 @@ type TestDeps struct { Hostname hostname.Component SharedForwarder defaultforwarder.Component Compressor compression.Component + HaAgent haagent.Component } // InitAndStartAgentDemultiplexerForTest initializes an aggregator for tests. func InitAndStartAgentDemultiplexerForTest(deps TestDeps, options AgentDemultiplexerOptions, hostname string) *AgentDemultiplexer { orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{}) eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(deps.Hostname)) - return InitAndStartAgentDemultiplexer(deps.Log, deps.SharedForwarder, &orchestratorForwarder, options, eventPlatformForwarder, deps.Compressor, nooptagger.NewComponent(), hostname) + return InitAndStartAgentDemultiplexer(deps.Log, deps.SharedForwarder, &orchestratorForwarder, options, eventPlatformForwarder, deps.HaAgent, deps.Compressor, nooptagger.NewComponent(), hostname) } diff --git a/pkg/aggregator/demultiplexer_test.go b/pkg/aggregator/demultiplexer_test.go index 6c3dd77976bdf..f95ab7020d3c8 100644 --- a/pkg/aggregator/demultiplexer_test.go +++ b/pkg/aggregator/demultiplexer_test.go @@ -21,6 +21,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/eventplatformreceiver/eventplatformreceiverimpl" orchestratorForwarder "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator" orchestratorForwarderImpl "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl" + haagentmock "github.com/DataDog/datadog-agent/comp/haagent/mock" "github.com/DataDog/datadog-agent/comp/serializer/compression" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" @@ -173,7 +174,7 @@ func TestDemuxFlushAggregatorToSerializer(t *testing.T) { opts := demuxTestOptions() opts.FlushInterval = time.Hour deps := createDemuxDeps(t, opts, eventplatformimpl.NewDefaultParams()) - demux := initAgentDemultiplexer(deps.Log, deps.SharedForwarder, deps.OrchestratorFwd, opts, deps.EventPlatformFwd, deps.Compressor, nooptagger.NewComponent(), "") + demux := initAgentDemultiplexer(deps.Log, deps.SharedForwarder, deps.OrchestratorFwd, opts, deps.EventPlatformFwd, deps.HaAgent, deps.Compressor, nooptagger.NewComponent(), "") demux.Aggregator().tlmContainerTagsEnabled = false require.NotNil(demux) require.NotNil(demux.aggregator) @@ -295,12 +296,13 @@ func createDemuxDepsWithOrchestratorFwd( eventplatformimpl.Module(eventPlatformParams), eventplatformreceiverimpl.Module(), compressionimpl.MockModule(), + haagentmock.Module(), ) deps := fxutil.Test[internalDemutiplexerDeps](t, modules) return aggregatorDeps{ TestDeps: deps.TestDeps, - Demultiplexer: InitAndStartAgentDemultiplexer(deps.Log, deps.SharedForwarder, deps.OrchestratorForwarder, opts, deps.Eventplatform, deps.Compressor, nooptagger.NewComponent(), ""), + Demultiplexer: InitAndStartAgentDemultiplexer(deps.Log, deps.SharedForwarder, deps.OrchestratorForwarder, opts, deps.Eventplatform, deps.HaAgent, deps.Compressor, nooptagger.NewComponent(), ""), OrchestratorFwd: deps.OrchestratorForwarder, EventPlatformFwd: deps.Eventplatform, } diff --git a/pkg/aggregator/mocksender/mocksender.go b/pkg/aggregator/mocksender/mocksender.go index e4403bdc352ef..309a07ae0b3bf 100644 --- a/pkg/aggregator/mocksender/mocksender.go +++ b/pkg/aggregator/mocksender/mocksender.go @@ -20,6 +20,7 @@ import ( "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" nooptagger "github.com/DataDog/datadog-agent/comp/core/tagger/impl-noop" + haagentmock "github.com/DataDog/datadog-agent/comp/haagent/mock" "github.com/DataDog/datadog-agent/pkg/aggregator" "github.com/DataDog/datadog-agent/pkg/aggregator/sender" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" @@ -43,7 +44,7 @@ func CreateDefaultDemultiplexer() *aggregator.AgentDemultiplexer { orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{}) eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(hostnameimpl.NewHostnameService())) taggerComponent := nooptagger.NewComponent() - return aggregator.InitAndStartAgentDemultiplexer(log, sharedForwarder, &orchestratorForwarder, opts, eventPlatformForwarder, compressionimpl.NewMockCompressor(), taggerComponent, "") + return aggregator.InitAndStartAgentDemultiplexer(log, sharedForwarder, &orchestratorForwarder, opts, eventPlatformForwarder, haagentmock.NewMockHaAgent(), compressionimpl.NewMockCompressor(), taggerComponent, "") } diff --git a/pkg/aggregator/sender_test.go b/pkg/aggregator/sender_test.go index 17713653a59bc..68045d0d04715 100644 --- a/pkg/aggregator/sender_test.go +++ b/pkg/aggregator/sender_test.go @@ -23,6 +23,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" + haagentmock "github.com/DataDog/datadog-agent/comp/haagent/mock" "github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" "github.com/DataDog/datadog-agent/pkg/metrics" @@ -58,7 +59,7 @@ func testDemux(log log.Component, hostname hostname.Component) *AgentDemultiplex opts.DontStartForwarders = true orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{}) eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(hostname)) - demux := initAgentDemultiplexer(log, NewForwarderTest(log), &orchestratorForwarder, opts, eventPlatformForwarder, compressionimpl.NewMockCompressor(), nooptagger.NewComponent(), defaultHostname) + demux := initAgentDemultiplexer(log, NewForwarderTest(log), &orchestratorForwarder, opts, eventPlatformForwarder, haagentmock.NewMockHaAgent(), compressionimpl.NewMockCompressor(), nooptagger.NewComponent(), defaultHostname) return demux } diff --git a/pkg/cli/subcommands/check/command.go b/pkg/cli/subcommands/check/command.go index f88bd1b8a2dc2..2da70cead3066 100644 --- a/pkg/cli/subcommands/check/command.go +++ b/pkg/cli/subcommands/check/command.go @@ -61,6 +61,7 @@ import ( "github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl" "github.com/DataDog/datadog-agent/comp/forwarder/eventplatformreceiver/eventplatformreceiverimpl" orchestratorForwarderImpl "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl" + haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx" logagent "github.com/DataDog/datadog-agent/comp/logs/agent" integrations "github.com/DataDog/datadog-agent/comp/logs/integrations/def" "github.com/DataDog/datadog-agent/comp/metadata/inventorychecks" @@ -212,6 +213,7 @@ func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command { getPlatformModules(), jmxloggerimpl.Module(jmxloggerimpl.NewDisabledParams()), + haagentfx.Module(), ) }, } diff --git a/pkg/collector/corechecks/snmp/integration_profile_bundle_test.go b/pkg/collector/corechecks/snmp/integration_profile_bundle_test.go index 720f4f713a35b..6e7c55f230fcc 100644 --- a/pkg/collector/corechecks/snmp/integration_profile_bundle_test.go +++ b/pkg/collector/corechecks/snmp/integration_profile_bundle_test.go @@ -25,7 +25,7 @@ import ( func TestProfileBundleJsonZip(t *testing.T) { timeNow = common.MockTimeNow - aggregator.NewBufferedAggregator(nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) + aggregator.NewBufferedAggregator(nil, nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) invalidPath, _ := filepath.Abs(filepath.Join("internal", "test", "zipprofiles.d")) pkgconfigsetup.Datadog().SetWithoutSource("confd_path", invalidPath) diff --git a/pkg/collector/corechecks/snmp/integration_profile_metadata_test.go b/pkg/collector/corechecks/snmp/integration_profile_metadata_test.go index 06b55c7df2180..68e82058528dd 100644 --- a/pkg/collector/corechecks/snmp/integration_profile_metadata_test.go +++ b/pkg/collector/corechecks/snmp/integration_profile_metadata_test.go @@ -32,7 +32,7 @@ import ( func TestProfileMetadata_f5(t *testing.T) { timeNow = common.MockTimeNow - aggregator.NewBufferedAggregator(nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) + aggregator.NewBufferedAggregator(nil, nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) invalidPath, _ := filepath.Abs(filepath.Join("internal", "test", "metadata.d")) pkgconfigsetup.Datadog().SetWithoutSource("confd_path", invalidPath) diff --git a/pkg/collector/corechecks/snmp/integration_topology_test.go b/pkg/collector/corechecks/snmp/integration_topology_test.go index 0f5ccfbc2e5f4..b4f0f42ceb6d0 100644 --- a/pkg/collector/corechecks/snmp/integration_topology_test.go +++ b/pkg/collector/corechecks/snmp/integration_topology_test.go @@ -32,7 +32,7 @@ import ( func TestTopologyPayload_LLDP(t *testing.T) { timeNow = common.MockTimeNow - aggregator.NewBufferedAggregator(nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) + aggregator.NewBufferedAggregator(nil, nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) invalidPath, _ := filepath.Abs(filepath.Join("internal", "test", "metadata.d")) pkgconfigsetup.Datadog().SetWithoutSource("confd_path", invalidPath) @@ -734,7 +734,7 @@ profiles: func TestTopologyPayload_CDP(t *testing.T) { timeNow = common.MockTimeNow - aggregator.NewBufferedAggregator(nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) + aggregator.NewBufferedAggregator(nil, nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) invalidPath, _ := filepath.Abs(filepath.Join("internal", "test", "metadata.d")) pkgconfigsetup.Datadog().SetWithoutSource("confd_path", invalidPath) @@ -1427,7 +1427,7 @@ profiles: // we have different data for LLDP and CDP to test that we're only using LLDP to build the links func TestTopologyPayload_LLDP_CDP(t *testing.T) { timeNow = common.MockTimeNow - aggregator.NewBufferedAggregator(nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) + aggregator.NewBufferedAggregator(nil, nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) invalidPath, _ := filepath.Abs(filepath.Join("internal", "test", "metadata.d")) pkgconfigsetup.Datadog().SetWithoutSource("confd_path", invalidPath) diff --git a/pkg/collector/corechecks/snmp/internal/checkconfig/config_test.go b/pkg/collector/corechecks/snmp/internal/checkconfig/config_test.go index ac8c0520fb1fc..d8536a4931cb6 100644 --- a/pkg/collector/corechecks/snmp/internal/checkconfig/config_test.go +++ b/pkg/collector/corechecks/snmp/internal/checkconfig/config_test.go @@ -25,7 +25,7 @@ import ( func TestConfigurations(t *testing.T) { profile.SetConfdPathAndCleanProfiles() - aggregator.NewBufferedAggregator(nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) + aggregator.NewBufferedAggregator(nil, nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) // language=yaml rawInstanceConfig := []byte(` @@ -326,7 +326,7 @@ profiles: func TestInlineProfileConfiguration(t *testing.T) { profile.SetConfdPathAndCleanProfiles() - aggregator.NewBufferedAggregator(nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) + aggregator.NewBufferedAggregator(nil, nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) // language=yaml rawInstanceConfig := []byte(` diff --git a/pkg/collector/corechecks/systemd/systemd_test.go b/pkg/collector/corechecks/systemd/systemd_test.go index 6f91dc4edd2fe..7fb9d67df981a 100644 --- a/pkg/collector/corechecks/systemd/systemd_test.go +++ b/pkg/collector/corechecks/systemd/systemd_test.go @@ -1087,7 +1087,7 @@ unit_names: func TestCheckID(t *testing.T) { check1 := newCheck() check2 := newCheck() - aggregator.NewBufferedAggregator(nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) + aggregator.NewBufferedAggregator(nil, nil, nil, nooptagger.NewComponent(), "", 1*time.Hour) // language=yaml rawInstanceConfig1 := []byte(` diff --git a/releasenotes/notes/NDMII-3154-ha-agent-comp-agent-group-metric-tag-66893d099fe880cc.yaml b/releasenotes/notes/NDMII-3154-ha-agent-comp-agent-group-metric-tag-66893d099fe880cc.yaml new file mode 100644 index 0000000000000..80412f488753f --- /dev/null +++ b/releasenotes/notes/NDMII-3154-ha-agent-comp-agent-group-metric-tag-66893d099fe880cc.yaml @@ -0,0 +1,11 @@ +# Each section from every release note are combined when the +# CHANGELOG.rst is rendered. So the text needs to be worded so that +# it does not depend on any information only available in another +# section. This may mean repeating some details, but each section +# must be readable independently of the other. +# +# Each section note must be formatted as reStructuredText. +--- +enhancements: + - | + [ha-agent] Add agent_group tag to datadog.agent.running metric diff --git a/test/benchmarks/kubernetes_state/main.go b/test/benchmarks/kubernetes_state/main.go index 08b83d358855e..a1ea844898a9b 100644 --- a/test/benchmarks/kubernetes_state/main.go +++ b/test/benchmarks/kubernetes_state/main.go @@ -207,7 +207,7 @@ func main() { * As it has a `nil` serializer, it will panic if it tries to flush the metrics. * That’s why we need a big enough flush interval */ - aggregator.NewBufferedAggregator(nil, "", 1*time.Hour) + aggregator.NewBufferedAggregator(nil, "", nil, 1*time.Hour) /* * Wait for informers to get populated