Skip to content

Commit 199b574

Browse files
authored
[OTAGENT-587] Add invoke task for the full host profiler (#42105)
### What does this PR do? Add invoke task for the full host profiler ### Motivation ### Describe how you validated your changes Run the task locally. ### Additional Notes Co-authored-by: olivier.gaca <[email protected]>
1 parent 75c542e commit 199b574

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@
715715
/tasks/unit_tests/omnibus_tests.py @DataDog/agent-build
716716
/tasks/unit_tests/testdata/components_src/ @DataDog/agent-runtimes
717717
/tasks/installer.py @DataDog/fleet
718+
/tasks/full_host_profiler.py @DataDog/opentelemetry-agent @DataDog/profiling-full-host
718719
/test/ @DataDog/agent-devx
719720
/test/benchmarks/ @DataDog/agent-metric-pipelines
720721
/test/benchmarks/kubernetes_state/ @DataDog/container-integrations

tasks/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
epforwarder,
3333
fakeintake,
3434
fips,
35+
full_host_profiler,
3536
git,
3637
github_tasks,
3738
gitlab_helpers,
@@ -209,6 +210,7 @@
209210
ns.add_collection(notify)
210211
ns.add_collection(oracle)
211212
ns.add_collection(otel_agent)
213+
ns.add_collection(full_host_profiler)
212214
ns.add_collection(sds)
213215
ns.add_collection(selinux)
214216
ns.add_collection(setup)

tasks/build_tags.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@
260260

261261
LOADER_TAGS = set()
262262

263+
FULL_HOST_PROFILER_TAGS = set()
264+
263265
# AGENT_TEST_TAGS lists the tags that have to be added to run tests
264266
AGENT_TEST_TAGS = AGENT_TAGS.union({"clusterchecks"})
265267

@@ -305,6 +307,7 @@
305307
"sbomgen": SBOMGEN_TAGS,
306308
"otel-agent": OTEL_AGENT_TAGS,
307309
"loader": LOADER_TAGS,
310+
"full-host-profiler": FULL_HOST_PROFILER_TAGS,
308311
# Test setups
309312
"test": AGENT_TEST_TAGS.union(UNIT_TEST_TAGS).difference(UNIT_TEST_EXCLUDE_TAGS),
310313
"lint": AGENT_TEST_TAGS.union(PROCESS_AGENT_TAGS).union(UNIT_TEST_TAGS).difference(UNIT_TEST_EXCLUDE_TAGS),

tasks/full_host_profiler.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import os
2+
import shutil
3+
import sys
4+
5+
from invoke import task
6+
from invoke.exceptions import Exit
7+
8+
from tasks.build_tags import get_default_build_tags
9+
from tasks.libs.common.go import go_build
10+
from tasks.libs.common.utils import REPO_PATH, bin_name, get_version_ldflags
11+
12+
BIN_NAME = "full-host-profiler"
13+
BIN_DIR = os.path.join(".", "bin", "full-host-profiler")
14+
BIN_PATH = os.path.join(BIN_DIR, bin_name("full-host-profiler"))
15+
16+
17+
@task
18+
def build(ctx):
19+
"""
20+
Build the full host profiler
21+
"""
22+
23+
if os.path.exists(BIN_PATH):
24+
os.remove(BIN_PATH)
25+
26+
env = {"GO111MODULE": "on"}
27+
build_tags = get_default_build_tags(build="full-host-profiler")
28+
ldflags = get_version_ldflags(ctx)
29+
if os.environ.get("DELVE"):
30+
gcflags = "all=-N -l"
31+
else:
32+
gcflags = ""
33+
34+
# generate windows resources
35+
if sys.platform == 'win32':
36+
raise Exit("Windows is not supported for full-host-profiler")
37+
38+
go_build(
39+
ctx,
40+
f"{REPO_PATH}/cmd/host-profiler",
41+
mod="readonly",
42+
build_tags=build_tags,
43+
ldflags=ldflags,
44+
gcflags=gcflags,
45+
bin_path=BIN_PATH,
46+
env=env,
47+
)
48+
49+
dist_folder = os.path.join(BIN_DIR, "dist")
50+
if os.path.exists(dist_folder):
51+
shutil.rmtree(dist_folder)
52+
os.mkdir(dist_folder)
53+
54+
shutil.copy(
55+
"./cmd/host-profiler/dist/host-profiler-config.yaml",
56+
os.path.join(dist_folder, "full-host-profiler-config.yaml"),
57+
)

tasks/go_deps.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@
8181
"entrypoint": "cmd/otel-agent",
8282
"platforms": ["linux/x64", "linux/arm64"],
8383
},
84+
"full-host-profiler": {
85+
"entrypoint": "cmd/host-profiler",
86+
"platforms": ["linux/x64", "linux/arm64"],
87+
},
8488
"loader": {
8589
"entrypoint": "cmd/loader",
8690
"platforms": ["linux/x64", "linux/arm64", "darwin/x64", "darwin/arm64"],

0 commit comments

Comments
 (0)