Skip to content

Commit

Permalink
[ASCII-1531] Split tagger component into interface and implementation (
Browse files Browse the repository at this point in the history
…#24922)

* split tagger component into component and implementation

* use an embedded struct to reduce boiler plate
  • Loading branch information
GustavoCaso committed Apr 26, 2024
1 parent f4ce4ec commit 9581bfe
Show file tree
Hide file tree
Showing 109 changed files with 689 additions and 670 deletions.
3 changes: 2 additions & 1 deletion cmd/agent/subcommands/diagnose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/log/logimpl"
"github.com/DataDog/datadog-agent/comp/core/secrets"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
"github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl"
Expand Down Expand Up @@ -102,7 +103,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
}),
fx.Supply(optional.NewNoneOption[collector.Component]()),
workloadmeta.Module(),
tagger.Module(),
taggerimpl.Module(),
fx.Provide(func(config config.Component) tagger.Params { return tagger.NewTaggerParamsForCoreAgent(config) }),
autodiscoveryimpl.Module(),
compressionimpl.Module(),
Expand Down
3 changes: 2 additions & 1 deletion cmd/agent/subcommands/flare/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig"
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
"github.com/DataDog/datadog-agent/comp/metadata/host/hostimpl"
Expand Down Expand Up @@ -116,7 +117,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
}
}),
workloadmeta.Module(),
tagger.OptionalModule(),
taggerimpl.OptionalModule(),
autodiscoveryimpl.OptionalModule(), // if forceLocal is true, we will start autodiscovery (loadComponents) later
flare.Module(),
fx.Supply(optional.NewNoneOption[collector.Component]()),
Expand Down
3 changes: 2 additions & 1 deletion cmd/agent/subcommands/jmx/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/settings/settingsimpl"
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
"github.com/DataDog/datadog-agent/comp/dogstatsd/pidmap"
Expand Down Expand Up @@ -166,7 +167,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
fx.Provide(func() eventplatformreceiver.Component { return nil }),
fx.Provide(func() optional.Option[collector.Component] { return optional.NewNoneOption[collector.Component]() }),
fx.Provide(tagger.NewTaggerParamsForCoreAgent),
tagger.Module(),
taggerimpl.Module(),
autodiscoveryimpl.Module(),
fx.Supply(optional.NewNoneOption[gui.Component]()),
agent.Bundle(),
Expand Down
3 changes: 2 additions & 1 deletion cmd/agent/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig"
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/telemetry"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
Expand Down Expand Up @@ -375,7 +376,7 @@ func getSharedFxOption() fx.Option {
rcservicemrfimpl.Module(),
remoteconfig.Bundle(),
fx.Provide(tagger.NewTaggerParamsForCoreAgent),
tagger.Module(),
taggerimpl.Module(),
autodiscoveryimpl.Module(),
fx.Provide(func(ac autodiscovery.Component) optional.Option[autodiscovery.Component] {
return optional.NewOption[autodiscovery.Component](ac)
Expand Down
3 changes: 2 additions & 1 deletion cmd/cluster-agent-cloudfoundry/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/settings/settingsimpl"
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
"github.com/DataDog/datadog-agent/comp/forwarder"
Expand Down Expand Up @@ -98,7 +99,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
}), // TODO(components): check what this must be for cluster-agent-cloudfoundry
workloadmeta.Module(),
fx.Provide(tagger.NewTaggerParams),
tagger.Module(),
taggerimpl.Module(),
collectorimpl.Module(),
fx.Provide(func() optional.Option[serializer.MetricSerializer] {
return optional.NewNoneOption[serializer.MetricSerializer]()
Expand Down
2 changes: 1 addition & 1 deletion cmd/cluster-agent/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

pbgo "github.com/DataDog/datadog-agent/pkg/proto/pbgo/core"

taggerserver "github.com/DataDog/datadog-agent/comp/core/tagger/server"
taggerserver "github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl/server"
)

type serverSecure struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cluster-agent/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/settings"
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/comp/core/tagger"
taggerserver "github.com/DataDog/datadog-agent/comp/core/tagger/server"
taggerserver "github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl/server"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/pkg/aggregator/sender"
"github.com/DataDog/datadog-agent/pkg/api/security"
Expand Down
3 changes: 2 additions & 1 deletion cmd/cluster-agent/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/comp/core/status/statusimpl"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/telemetry"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
Expand Down Expand Up @@ -152,7 +153,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
fx.Supply(context.Background()),
workloadmeta.Module(),
fx.Provide(tagger.NewTaggerParams),
tagger.Module(),
taggerimpl.Module(),
fx.Supply(
status.Params{
PythonVersionGetFunc: python.GetPythonVersion,
Expand Down
3 changes: 2 additions & 1 deletion cmd/dogstatsd/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/secrets"
"github.com/DataDog/datadog-agent/comp/core/secrets/secretsimpl"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
"github.com/DataDog/datadog-agent/comp/dogstatsd"
Expand Down Expand Up @@ -152,7 +153,7 @@ func RunDogstatsdFct(cliParams *CLIParams, defaultConfPath string, defaultLogFil
eventplatformreceiverimpl.Module(),
hostnameimpl.Module(),
fx.Supply(eventplatformimpl.NewDisabledParams()),
tagger.OptionalModule(),
taggerimpl.OptionalModule(),
// injecting the shared Serializer to FX until we migrate it to a prpoper component. This allows other
// already migrated components to request it.
fx.Provide(func(demuxInstance demultiplexer.Component) serializer.MetricSerializer {
Expand Down
3 changes: 2 additions & 1 deletion cmd/process-agent/command/main_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig"
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
compstatsd "github.com/DataDog/datadog-agent/comp/dogstatsd/statsd"
Expand Down Expand Up @@ -139,7 +140,7 @@ func runApp(ctx context.Context, globalParams *GlobalParams) error {
workloadmeta.Module(),

// Provide tagger module
tagger.Module(),
taggerimpl.Module(),

// Provide status modules
statusimpl.Module(),
Expand Down
3 changes: 2 additions & 1 deletion cmd/process-agent/subcommands/check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/log/logimpl"
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
hostMetadataUtils "github.com/DataDog/datadog-agent/comp/metadata/host/hostimpl/utils"
Expand Down Expand Up @@ -123,7 +124,7 @@ func MakeCommand(globalParams *command.GlobalParams, name string, allowlist []st
}),

// Provide tagger module
tagger.Module(),
taggerimpl.Module(),
// Tagger must be initialized after agent config has been setup
fx.Provide(func(c config.Component) tagger.Params {
if c.GetBool("process_config.remote_tagger") {
Expand Down
4 changes: 2 additions & 2 deletions cmd/process-agent/subcommands/taggerlist/tagger_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +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"
tagger_api "github.com/DataDog/datadog-agent/comp/core/tagger/api"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl/api"
ddconfig "github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
)
Expand Down Expand Up @@ -58,7 +58,7 @@ func taggerList(deps dependencies) error {
return err
}

return tagger_api.GetTaggerList(color.Output, taggerURL)
return api.GetTaggerList(color.Output, taggerURL)
}

func getTaggerURL() (string, error) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/security-agent/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig"
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/telemetry"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
Expand Down Expand Up @@ -112,7 +113,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
AgentType: catalog,
}
}),
tagger.Module(),
taggerimpl.Module(),
fx.Provide(func(config config.Component) tagger.Params {
if config.GetBool("security_agent.remote_tagger") {
return tagger.NewNodeRemoteTaggerParams()
Expand Down
3 changes: 2 additions & 1 deletion cmd/trace-agent/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/secrets"
"github.com/DataDog/datadog-agent/comp/core/secrets/secretsimpl"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
"github.com/DataDog/datadog-agent/comp/dogstatsd/statsd"
Expand Down Expand Up @@ -97,7 +98,7 @@ func runTraceAgentProcess(ctx context.Context, cliParams *Params, defaultConfPat
}
return tagger.NewTaggerParams()
}),
tagger.Module(),
taggerimpl.Module(),
fx.Invoke(func(_ config.Component) {}),
// Required to avoid cyclic imports.
fx.Provide(func(cfg config.Component) telemetry.TelemetryCollector { return telemetry.NewCollector(cfg.Object()) }),
Expand Down
3 changes: 2 additions & 1 deletion comp/api/api/apiimpl/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/comp/core/status/statusimpl"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/dogstatsd/replay"
dogstatsdServer "github.com/DataDog/datadog-agent/comp/dogstatsd/server"
Expand Down Expand Up @@ -113,7 +114,7 @@ func getComponentDependencies(t *testing.T) testdeps {
fx.Supply(optional.NewNoneOption[rcservicemrf.Component]()),
fetchonlyimpl.MockModule(),
fx.Supply(context.Background()),
tagger.MockModule(),
taggerimpl.MockModule(),
fx.Supply(autodiscoveryimpl.MockParams{Scheduler: nil}),
autodiscoveryimpl.MockModule(),
fx.Provide(func() optional.Option[logsAgent.Component] {
Expand Down
4 changes: 2 additions & 2 deletions comp/api/api/apiimpl/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
workloadmetaServer "github.com/DataDog/datadog-agent/comp/core/workloadmeta/server"

"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/tagger/replay"
taggerserver "github.com/DataDog/datadog-agent/comp/core/tagger/server"
"github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl/replay"
taggerserver "github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl/server"
"github.com/DataDog/datadog-agent/comp/dogstatsd/pidmap"
dsdReplay "github.com/DataDog/datadog-agent/comp/dogstatsd/replay"
dogstatsdServer "github.com/DataDog/datadog-agent/comp/dogstatsd/server"
Expand Down
2 changes: 1 addition & 1 deletion comp/api/api/apiimpl/server_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/settings"
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/comp/core/tagger"
taggerserver "github.com/DataDog/datadog-agent/comp/core/tagger/server"
taggerserver "github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl/server"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
workloadmetaServer "github.com/DataDog/datadog-agent/comp/core/workloadmeta/server"
"github.com/DataDog/datadog-agent/comp/dogstatsd/pidmap"
Expand Down
8 changes: 4 additions & 4 deletions comp/core/tagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function, and returns an empty list on errors.

## Collector

A **Collector** connects to a single information source and pushes **TagInfo**
A **Collector** connects to a single information source and pushes **types.TagInfo**
structs to a channel, towards the **Tagger**. It can either run in streaming
mode, pull or fetchonly mode, depending of what's most efficient for the data source:

Expand All @@ -40,18 +40,18 @@ The **ECSCollector** does not push updates to the Store by itself, but is only t

## TagStore

The **TagStore** reads **TagInfo** structs and stores them in a in-memory
The **TagStore** reads **types.TagInfo** structs and stores them in a in-memory
cache. Cache invalidation is triggered by the collectors (or source) by either:

* sending new tags for the same `Entity`, all the tags from this `Source`
will be removed and replaced by the new tags
* sending a **TagInfo** with **DeleteEntity** set, all the tags collected for
* sending a **types.TagInfo** with **DeleteEntity** set, all the tags collected for
this entity by the specified source (but not others) will be deleted when
**prune()** is called.

## TagCardinality

**TagInfo** accepts and store tags that have different cardinality. **TagCardinality** can be:
**types.TagInfo** accepts and store tags that have different cardinality. **TagCardinality** can be:

* **LowCardinality**: in the host count order of magnitude
* **OrchestratorCardinality**: tags that change value for each pod or task
Expand Down
16 changes: 0 additions & 16 deletions comp/core/tagger/api/response.go

This file was deleted.

46 changes: 0 additions & 46 deletions comp/core/tagger/collectors/types.go

This file was deleted.

Loading

0 comments on commit 9581bfe

Please sign in to comment.