Skip to content

Commit 4eae01b

Browse files
committed
Merge branch 'main' into rayz/trigger-otlp-ingest-metrics-experiment
2 parents 6a99d54 + e786e6c commit 4eae01b

226 files changed

Lines changed: 6492 additions & 1349 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
/MODULE.bazel* @DataDog/agent-build
3030
# Temporary during Bazel migration
3131
/**/BUILD.bazel @DataDog/agent-build
32+
# This should really be to a team that does not exist yet. It would cover supply chain in general.
33+
# For now, agent-build are the experts in that.
34+
/third_party/ @DataDog/agent-build
3235

3336
/CHANGELOG.rst @DataDog/agent-delivery
3437
/CHANGELOG-DCA.rst @DataDog/container-integrations @DataDog/container-platform
@@ -262,6 +265,7 @@
262265
/cmd/system-probe/windows_resources/ @DataDog/windows-products
263266
/cmd/system-probe/main_windows*.go @DataDog/windows-products
264267
/cmd/system-probe/subcommands/runtime/ @DataDog/agent-security
268+
/cmd/system-probe/subcommands/usm/ @DataDog/universal-service-monitoring
265269
/cmd/systray/ @DataDog/windows-products
266270
/cmd/security-agent/ @DataDog/agent-security
267271
/cmd/installer/ @DataDog/fleet @DataDog/windows-products
@@ -378,6 +382,7 @@
378382
/comp/snmpscan @DataDog/ndm-core
379383
/comp/softwareinventory @DataDog/windows-products
380384
/comp/syntheticstestscheduler @DataDog/synthetics-executing
385+
/comp/workloadselection @DataDog/injection-platform
381386
# END COMPONENTS
382387

383388
# Additional notification to @iglendd about Agent Telemetry changes for optional approval and governance acknowledgement

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ devenv/packer_cache
172172
test_output.json
173173
module_test_output.json
174174
e2e_test_output.json
175+
e2e_test_output.json.*.part
176+
junit-out-AgentFlavor.base-*.xml
175177

176178
# doxygen doc & error log
177179
rtloader/doc

.gitlab/bazel/build-deps.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ bazel:build-deps:windows-amd64:
4747
ARCH: x64
4848
SCRIPT: |-
4949
echo "🟡 TODO(regis): compilation errors remain - limiting to a working subset for the time being"
50-
bazel build '@zlib//...' '@libffi'
50+
bazel build '@zlib//...' '@libffi//:ffi'
5151
# bazel build @bzip2//...

.gitlab/bazel/defs.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,20 @@
3737
$PSNativeCommandUseErrorActionPreference = $true
3838
Set-StrictMode -Version 3.0
3939
'@
40-
- Invoke-Expression $FailFast
40+
Invoke-Expression $FailFast
41+
$Utf8Script = [Text.Encoding]::UTF8.GetString([Text.Encoding]::GetEncoding([Console]::OutputEncoding.CodePage).GetBytes($SCRIPT))
42+
$EncodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes("$FailFast`n$Utf8Script"))
4143
- >-
42-
(($FailFast, $SCRIPT) -join [Environment]::NewLine) | docker run
44+
docker run
4345
--env=BAZELISK_HOME
4446
--env=BAZEL_DISK_CACHE
4547
--env=BAZEL_OUTPUT_USER_ROOT
4648
--env=BAZEL_REPO_CONTENTS_CACHE
4749
--env=CI_PROJECT_DIR
4850
--env=RUNNER_TEMP_PROJECT_DIR
49-
--interactive
5051
--rm
5152
--volume="${CI_PROJECT_DIR}:$CI_PROJECT_DIR"
5253
--volume="${RUNNER_TEMP_PROJECT_DIR}:$RUNNER_TEMP_PROJECT_DIR"
5354
--workdir="$CI_PROJECT_DIR"
5455
"$WINBUILDIMAGE"
55-
powershell -Command -
56+
powershell -NonInteractive -NoLogo -NoProfile -OutputFormat Text -EncodedCommand $EncodedCommand

Dockerfiles/agent/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ RUN --mount=from=artifacts,target=/artifacts \
161161
&& rm -rf usr etc/init lib \
162162
go/ \
163163
opt/datadog-agent/embedded/bin/installer \
164+
opt/datadog-agent/embedded/bin/dd-compile-policy \
164165
opt/datadog-agent/sources \
165166
opt/datadog-agent/embedded/share/doc \
166167
opt/datadog-agent/embedded/share/man \

MODULE.bazel

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,48 @@ multitool.hub(lockfile = "//bazel:prebuilt_buildtools.json")
4141
multitool.hub(lockfile = "//bazel:prebuilt_jq.json")
4242
use_repo(multitool, "multitool")
4343

44-
#########################
45-
## Compilers ##
46-
#########################
44+
######################################
45+
## Compilers and toolchains ##
46+
####################################
4747

4848
bazel_dep(name = "rules_cc", version = "0.2.8")
4949
bazel_dep(name = "rules_python", version = "1.6.1")
5050
bazel_dep(name = "rules_flex", version = "0.4")
5151
bazel_dep(name = "rules_m4", version = "0.3")
52+
bazel_dep(name = "gcc_toolchain", version = "0.9.0")
53+
git_override(
54+
module_name = "gcc_toolchain",
55+
commit = "0e2242b07961107d2b05a6552d70b2ef4ef485fb",
56+
patch_args = ["-p1"],
57+
patches = [
58+
"//bazel/patches:datadog_agent_toolchain.patch",
59+
"//bazel/patches:0001-fix-c-x86_64-header-locations-with-our-ctng-toolchai.patch",
60+
],
61+
remote = "https://github.com/f0rmiga/gcc-toolchain.git",
62+
)
63+
64+
gcc_toolchains = use_extension("@gcc_toolchain//toolchain:module_extensions.bzl", "gcc_toolchains", dev_dependency = True)
65+
gcc_toolchains.toolchain(
66+
name = "gcc_toolchain_x86_64",
67+
binary_prefix = "x86_64-unknown-linux-gnu-",
68+
gcc_version = "11.4.0",
69+
target_arch = "x86_64",
70+
)
71+
gcc_toolchains.toolchain(
72+
name = "gcc_toolchain_aarch64",
73+
binary_prefix = "aarch64-unknown-linux-gnu-",
74+
gcc_version = "12.3.0",
75+
target_arch = "aarch64",
76+
)
77+
use_repo(gcc_toolchains, "gcc_toolchain_x86_64")
78+
use_repo(gcc_toolchains, "gcc_toolchain_aarch64")
79+
80+
# TODO{agent-build}: Find a way to register platform-specific toolchains dynamically
81+
register_toolchains(
82+
"@gcc_toolchain_x86_64//:cc_toolchain",
83+
"@gcc_toolchain_aarch64//:cc_toolchain",
84+
"//bazel/toolchains/mingw:mingw_cc_toolchain",
85+
)
5286

5387
#########################
5488
## Native dependencies ##

cmd/agent/subcommands/run/command.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
agenttelemetryfx "github.com/DataDog/datadog-agent/comp/core/agenttelemetry/fx"
3535
"github.com/DataDog/datadog-agent/comp/core/autodiscovery/providers/datastreams"
3636
ssistatusfx "github.com/DataDog/datadog-agent/comp/updater/ssistatus/fx"
37+
workloadselectionfx "github.com/DataDog/datadog-agent/comp/workloadselection/fx"
3738

3839
haagentfx "github.com/DataDog/datadog-agent/comp/haagent/fx"
3940
snmpscanfx "github.com/DataDog/datadog-agent/comp/snmpscan/fx"
@@ -534,6 +535,7 @@ func getSharedFxOption() fx.Option {
534535
diagnosefx.Module(),
535536
ipcfx.ModuleReadWrite(),
536537
ssistatusfx.Module(),
538+
workloadselectionfx.Module(),
537539
workloadfilterfx.Module(),
538540
connectivitycheckerfx.Module(),
539541
configstreamfx.Module(),

cmd/host-profiler/dist/host-profiler-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
extensions:
2+
ddprofiling/default:
13
receivers:
2-
ddprofiling:
4+
hostprofiler:
35
processors:
46
infraattributes/default:
5-
cardinality: 2 #HighCardinality
7+
cardinality: 2 # HighCardinality
68
exporters:
79
debug: {}
810
otlphttp:
@@ -11,9 +13,11 @@ exporters:
1113
dd-api-key: ${env:DD_API_KEY}
1214
profiles_endpoint: https://intake.profile.datad0g.com/api/v2/profotlp
1315
service:
16+
# ddprofiling/default is automatically removed when the Agent Core is not available
17+
# extensions: [ddprofiling/default]
1418
pipelines:
1519
profiles:
16-
receivers: [ddprofiling]
20+
receivers: [hostprofiler]
1721
# infraattributes/default is automatically removed when the Agent Core is not available
1822
processors: [infraattributes/default]
1923
exporters: [otlphttp, debug]

cmd/host-profiler/subcommands/run/command.go

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,23 @@ import (
2525
secretfx "github.com/DataDog/datadog-agent/comp/core/secrets/fx"
2626
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
2727
remoteTaggerFx "github.com/DataDog/datadog-agent/comp/core/tagger/fx-remote"
28+
"github.com/DataDog/datadog-agent/comp/dogstatsd/statsd"
29+
statsdotel "github.com/DataDog/datadog-agent/comp/dogstatsd/statsd/otel"
2830
hostprofiler "github.com/DataDog/datadog-agent/comp/host-profiler"
2931
collector "github.com/DataDog/datadog-agent/comp/host-profiler/collector/def"
3032
collectorimpl "github.com/DataDog/datadog-agent/comp/host-profiler/collector/impl"
33+
"github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/metricsclient"
34+
traceagentfx "github.com/DataDog/datadog-agent/comp/trace/agent/fx"
35+
traceagentcomp "github.com/DataDog/datadog-agent/comp/trace/agent/impl"
36+
gzipfx "github.com/DataDog/datadog-agent/comp/trace/compression/fx-gzip"
37+
traceconfig "github.com/DataDog/datadog-agent/comp/trace/config"
38+
payloadmodifierfx "github.com/DataDog/datadog-agent/comp/trace/payload-modifier/fx"
39+
pkgconfigmodel "github.com/DataDog/datadog-agent/pkg/config/model"
3140
"github.com/DataDog/datadog-agent/pkg/config/setup"
41+
"github.com/DataDog/datadog-agent/pkg/trace/telemetry"
3242
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
43+
"github.com/DataDog/datadog-agent/pkg/util/fxutil/logging"
44+
ddgostatsd "github.com/DataDog/datadog-go/v5/statsd"
3345
)
3446

3547
type cliParams struct {
@@ -57,9 +69,10 @@ func MakeCommand(globalConfGetter func() *globalparams.GlobalParams) []*cobra.Co
5769
return []*cobra.Command{cmd}
5870
}
5971

60-
func runHostProfilerCommand(_ context.Context, cliParams *cliParams) error {
72+
func runHostProfilerCommand(ctx context.Context, cliParams *cliParams) error {
6173
var opts []fx.Option = []fx.Option{
6274
hostprofiler.Bundle(collectorimpl.NewParams(cliParams.GlobalParams.ConfFilePath)),
75+
logging.DefaultFxLoggingOption(),
6376
}
6477

6578
if cliParams.GlobalParams.CoreConfPath != "" {
@@ -69,12 +82,11 @@ func runHostProfilerCommand(_ context.Context, cliParams *cliParams) error {
6982
ConfigParams: config.NewAgentParams(cliParams.GlobalParams.CoreConfPath),
7083
LogParams: log.ForDaemon(command.LoggerName, "log_file", setup.DefaultHostProfilerLogFile),
7184
}),
85+
fx.Provide(collectorimpl.NewExtraFactoriesWithAgentCore),
86+
)
87+
opts = append(opts, getRemoteTaggerOptions(cliParams)...)
88+
opts = append(opts, getTraceAgentOptions(ctx)...)
7289

73-
ipcfx.ModuleReadOnly(),
74-
secretfx.Module(),
75-
remoteTaggerFx.Module(tagger.NewRemoteParams()),
76-
configsyncimpl.Module(configsyncimpl.NewParams(cliParams.SyncTimeout, true, cliParams.SyncOnInitTimeout)),
77-
fx.Provide(collectorimpl.NewExtraFactoriesWithAgentCore))
7890
} else {
7991
opts = append(opts, fx.Provide(collectorimpl.NewExtraFactoriesWithoutAgentCore))
8092
}
@@ -85,3 +97,44 @@ func runHostProfilerCommand(_ context.Context, cliParams *cliParams) error {
8597
func run(collector collector.Component) error {
8698
return collector.Run()
8799
}
100+
101+
func getRemoteTaggerOptions(cliParams *cliParams) []fx.Option {
102+
return []fx.Option{
103+
ipcfx.ModuleReadOnly(),
104+
secretfx.Module(),
105+
remoteTaggerFx.Module(tagger.NewRemoteParams()),
106+
configsyncimpl.Module(configsyncimpl.NewParams(cliParams.SyncTimeout, true, cliParams.SyncOnInitTimeout)),
107+
}
108+
}
109+
110+
func getTraceAgentOptions(ctx context.Context) []fx.Option {
111+
return []fx.Option{
112+
traceagentfx.Module(),
113+
traceconfig.Module(),
114+
115+
fx.Supply(&traceagentcomp.Params{
116+
CPUProfile: "",
117+
MemProfile: "",
118+
PIDFilePath: "",
119+
DisableInternalProfiling: true,
120+
}),
121+
fx.Provide(func(cfg traceconfig.Component) telemetry.TelemetryCollector {
122+
return telemetry.NewCollector(cfg.Object())
123+
}),
124+
fx.Supply(metricsclient.NewStatsdClientWrapper(&ddgostatsd.NoOpClient{})),
125+
fx.Provide(func(client *metricsclient.StatsdClientWrapper) statsd.Component {
126+
return statsdotel.NewOTelStatsd(client)
127+
}),
128+
129+
gzipfx.Module(),
130+
payloadmodifierfx.NilModule(),
131+
fx.Supply(fx.Annotate(ctx, fx.As(new(context.Context)))),
132+
133+
fx.Decorate(func(config config.Component) config.Component {
134+
config.Set("apm_config.debug.port", 0, pkgconfigmodel.SourceDefault) // Disabled as in the otel-agent
135+
config.Set(setup.OTLPTracePort, 0, pkgconfigmodel.SourceDefault) // Disabled as in the otel-agent
136+
config.Set("apm_config.receiver_enabled", false, pkgconfigmodel.SourceDefault) // disable HTTP receiver
137+
return config
138+
}),
139+
}
140+
}

cmd/otel-agent/subcommands/run/command.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
workloadmetafx "github.com/DataDog/datadog-agent/comp/core/workloadmeta/fx"
3939
workloadmetainit "github.com/DataDog/datadog-agent/comp/core/workloadmeta/init"
4040
"github.com/DataDog/datadog-agent/comp/dogstatsd/statsd"
41+
statsdotel "github.com/DataDog/datadog-agent/comp/dogstatsd/statsd/otel"
4142
"github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder"
4243
"github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorinterface"
4344
logconfig "github.com/DataDog/datadog-agent/comp/logs/agent/config"
@@ -146,7 +147,7 @@ func runOTelAgentCommand(ctx context.Context, params *cliParams, opts ...fx.Opti
146147
inventoryagentimpl.Module(),
147148
fx.Supply(metricsclient.NewStatsdClientWrapper(&ddgostatsd.NoOpClient{})),
148149
fx.Provide(func(client *metricsclient.StatsdClientWrapper) statsd.Component {
149-
return statsd.NewOTelStatsd(client)
150+
return statsdotel.NewOTelStatsd(client)
150151
}),
151152
ipcfx.ModuleReadWrite(),
152153
collectorfx.Module(collectorimpl.NewParams(params.BYOC)),

0 commit comments

Comments
 (0)