Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ha-agent] Add agent_group tag to datadog.agent.running metric #31156

Merged
merged 33 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
af96a94
[haagent] Add haagent component
AlexandreYang Nov 18, 2024
e3bd8e5
[haagent] Add agent group tag to datadog.agent.running
AlexandreYang Nov 18, 2024
6aa49e7
add copy
AlexandreYang Nov 20, 2024
0bba3f8
fix comp
AlexandreYang Nov 20, 2024
48f0886
add reno
AlexandreYang Nov 20, 2024
3be2301
Merge branch 'NDMII-3154-ha-agent-comp' into NDMII-3154-ha-agent-comp…
AlexandreYang Nov 20, 2024
98c3152
rename package
AlexandreYang Nov 20, 2024
f13ec2a
revert func sig
AlexandreYang Nov 20, 2024
6f7a6b8
sort import
AlexandreYang Nov 20, 2024
6ae30cd
rename to noopHaAgent
AlexandreYang Nov 20, 2024
e052635
update .github/CODEOWNERS
AlexandreYang Nov 20, 2024
126a81c
Merge branch 'NDMII-3154-ha-agent-comp' into NDMII-3154-ha-agent-comp…
AlexandreYang Nov 20, 2024
c7da32d
update team
AlexandreYang Nov 21, 2024
0721a71
simplify mock
AlexandreYang Nov 21, 2024
f493937
fix cmd/agent/subcommands/diagnose/command.go
AlexandreYang Nov 21, 2024
65d8ac6
fix team
AlexandreYang Nov 21, 2024
2e6078b
update owner
AlexandreYang Nov 21, 2024
2d725b7
Merge branch 'NDMII-3154-ha-agent-comp' into NDMII-3154-ha-agent-comp…
AlexandreYang Nov 21, 2024
dae3005
clean up
AlexandreYang Nov 21, 2024
9b29cc9
revert unintended changes
AlexandreYang Nov 21, 2024
b1c7cf0
fix lint
AlexandreYang Nov 21, 2024
d8d3965
rename
AlexandreYang Nov 21, 2024
e9ffed6
fix tests
AlexandreYang Nov 21, 2024
6c74afc
Merge branch 'main' into NDMII-3154-ha-agent-comp-agent-group-metric-tag
AlexandreYang Nov 21, 2024
d33125a
add reno
AlexandreYang Nov 21, 2024
f1e9353
remove dep
AlexandreYang Nov 21, 2024
ae4f2eb
revert cmd/serverless/dependencies_linux*
AlexandreYang Nov 21, 2024
be0d8ea
add dep
AlexandreYang Nov 21, 2024
25a2bc3
try fix TestFxRunCommand
AlexandreYang Nov 24, 2024
5d03ac0
test demultiplexer_mock.go
AlexandreYang Nov 24, 2024
79ddc2c
empty
AlexandreYang Nov 24, 2024
0c4d4f8
Merge branch 'main' into NDMII-3154-ha-agent-comp-agent-group-metric-tag
AlexandreYang Nov 24, 2024
b06fc67
Merge branch 'main' into NDMII-3154-ha-agent-comp-agent-group-metric-tag
AlexandreYang Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/agent/subcommands/diagnose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -106,6 +107,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
autodiscoveryimpl.Module(),
compressionimpl.Module(),
diagnosesendermanagerimpl.Module(),
haagentfx.Module(),
)
},
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/subcommands/flare/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -144,6 +145,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
return nil
}),
core.Bundle(),
haagentfx.Module(),
)
},
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/subcommands/jmx/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -167,6 +168,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
proccontainers.InitSharedContainerProvider(wmeta, tagger)
}),
fx.Provide(func() remoteagentregistry.Component { return nil }),
haagentfx.Module(),
)
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/agent/subcommands/snmp/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cmd/cluster-agent-cloudfoundry/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
)
},
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/cluster-agent/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
)
},
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/dogstatsd/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -173,6 +174,7 @@ func RunDogstatsdFct(cliParams *CLIParams, defaultConfPath string, defaultLogFil
}
}),
healthprobefx.Module(),
haagentfx.Module(),
)
}

Expand Down
1 change: 1 addition & 0 deletions cmd/serverless/dependencies_linux_amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder/transaction
github.com/DataDog/datadog-agent/comp/forwarder/eventplatform
github.com/DataDog/datadog-agent/comp/forwarder/orchestrator
github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorinterface
github.com/DataDog/datadog-agent/comp/haagent/def
github.com/DataDog/datadog-agent/comp/logs/agent
github.com/DataDog/datadog-agent/comp/logs/agent/agentimpl
github.com/DataDog/datadog-agent/comp/logs/agent/config
Expand Down
1 change: 1 addition & 0 deletions cmd/serverless/dependencies_linux_arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder/transaction
github.com/DataDog/datadog-agent/comp/forwarder/eventplatform
github.com/DataDog/datadog-agent/comp/forwarder/orchestrator
github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorinterface
github.com/DataDog/datadog-agent/comp/haagent/def
github.com/DataDog/datadog-agent/comp/logs/agent
github.com/DataDog/datadog-agent/comp/logs/agent/agentimpl
github.com/DataDog/datadog-agent/comp/logs/agent/config
Expand Down
2 changes: 2 additions & 0 deletions cmd/systray/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
)
},
}
Expand Down
2 changes: 2 additions & 0 deletions comp/aggregator/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -26,5 +27,6 @@ func TestBundleDependencies(t *testing.T) {
orchestratorForwarderImpl.MockModule(),
eventplatformimpl.MockModule(),
nooptagger.Module(),
haagentmock.Module(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -86,6 +88,7 @@ func newDemultiplexer(deps dependencies) (provides, error) {
deps.OrchestratorForwarder,
options,
deps.EventPlatformForwarder,
deps.HaAgent,
deps.Compressor,
deps.Tagger,
hostnameDetected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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, "")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -39,6 +40,7 @@ type dependencies struct {
Hostname hostname.Component
Compressor compression.Component
Tagger tagger.Component
HaAgent haagent.Component
}

type diagnoseSenderManager struct {
Expand Down Expand Up @@ -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))
Expand All @@ -78,6 +81,7 @@ func (sender *diagnoseSenderManager) LazyGetSenderManager() (sender.SenderManage
orchestratorForwarder,
opts,
eventPlatformForwarder,
haAgent,
sender.deps.Compressor,
sender.deps.Tagger,
hostnameDetected)
Expand Down
53 changes: 38 additions & 15 deletions comp/haagent/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
}
8 changes: 7 additions & 1 deletion pkg/aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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{}),
Expand Down Expand Up @@ -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 {
Expand Down
Loading
Loading