Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d76a11d
chore(internal): add process_tags to first span of each payload
dubloom Nov 4, 2025
a3643d8
tests(process_tags): add tests
dubloom Nov 5, 2025
a52e8cc
lint
dubloom Nov 5, 2025
f943f2a
fix: suitespec
dubloom Nov 5, 2025
660bd64
fix: telemetry test
dubloom Nov 5, 2025
ace7fae
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 5, 2025
78dd521
fix telemetry 2
dubloom Nov 5, 2025
dd58490
simplify process_tags (brett review)
dubloom Nov 6, 2025
f47539e
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 6, 2025
184ef53
update python version
dubloom Nov 6, 2025
be2973e
put tests within internal suite
dubloom Nov 6, 2025
c6b4d7f
remove sys hack
dubloom Nov 6, 2025
c6cb1be
make tests compatible with CI
dubloom Nov 7, 2025
974b474
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 7, 2025
7416466
lint
dubloom Nov 7, 2025
0428dcd
brett review
dubloom Nov 10, 2025
b66d6a4
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 10, 2025
71b5ed7
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 12, 2025
a123350
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 12, 2025
32ddf35
improve tag normalization
dubloom Nov 14, 2025
ee77b0e
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 14, 2025
f5c3eee
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 17, 2025
7cf4143
gab review
dubloom Nov 17, 2025
67a7d46
chore(telemetry): add process tags
dubloom Nov 6, 2025
a238b27
first attempt for fix
dubloom Nov 12, 2025
9a4deb2
just checking the value is here
dubloom Nov 12, 2025
813fe51
typing
dubloom Nov 17, 2025
ae20207
improving normalization
dubloom Nov 18, 2025
f70b7ed
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 18, 2025
efe28fa
remove print
dubloom Nov 18, 2025
f957552
Update tests/internal/test_process_tags.py
dubloom Nov 18, 2025
86f04db
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 19, 2025
914d52a
add a test that activates the feature with env variable
dubloom Nov 19, 2025
7395edb
fix tests
dubloom Nov 19, 2025
fdd6480
chore(di): add process_tags (#15225)
dubloom Nov 19, 2025
be18663
Merge branch 'dubloom/process-tags-collection' into dubloom/process-t…
dubloom Nov 19, 2025
fa3dbb8
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 19, 2025
8341969
remove circular dependency
dubloom Nov 19, 2025
aa23d07
lint
dubloom Nov 19, 2025
30436ab
Merge branch 'main' into dubloom/process-tags-collection
dubloom Nov 20, 2025
0436b6f
Merge branch 'dubloom/process-tags-collection' into dubloom/process-t…
dubloom Nov 20, 2025
1200eca
Merge branch 'main' into dubloom/process-tags-telemetry
dubloom Nov 20, 2025
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
4 changes: 2 additions & 2 deletions ddtrace/internal/process_tags/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Optional

from ddtrace.internal.logger import get_logger
from ddtrace.internal.settings._config import config
from ddtrace.internal.settings.process_tags import process_tags_config as config


log = get_logger(__name__)
Expand Down Expand Up @@ -45,7 +45,7 @@ def is_allowed_char(char: str) -> str:


def generate_process_tags() -> Optional[str]:
if not config._process_tags_enabled:
if not config.enabled:
return None

try:
Expand Down
15 changes: 15 additions & 0 deletions ddtrace/internal/settings/process_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from ddtrace.internal.settings._core import DDConfig


class ProcessTagsConfig(DDConfig):
__prefix__ = "dd"

enabled = DDConfig.v(
bool,
"experimental.propagate.process.tags.enabled",
default=False,
help="Enables process tags in products payload",
)


process_tags_config = ProcessTagsConfig()
8 changes: 7 additions & 1 deletion ddtrace/internal/telemetry/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import List # noqa:F401
from typing import Tuple # noqa:F401

from ddtrace.internal import process_tags
from ddtrace.internal.constants import DEFAULT_SERVICE_NAME
from ddtrace.internal.packages import get_module_distribution_versions
from ddtrace.internal.runtime.container import get_container_info
Expand Down Expand Up @@ -58,7 +59,7 @@ def _get_application(key):
"""
service, version, env = key

return {
application = {
"service_name": service or DEFAULT_SERVICE_NAME, # mandatory field, can not be empty
"service_version": version or "",
"env": env or "",
Expand All @@ -69,6 +70,11 @@ def _get_application(key):
"runtime_version": _format_version_info(sys.implementation.version),
}

if p_tags := process_tags.process_tags:
application["process_tags"] = p_tags

return application


def update_imported_dependencies(already_imported: Dict[str, str], new_modules: Iterable[str]) -> List[Dict[str, str]]:
deps = []
Expand Down
16 changes: 8 additions & 8 deletions tests/internal/test_process_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ddtrace.internal.process_tags import ENTRYPOINT_TYPE_TAG
from ddtrace.internal.process_tags import ENTRYPOINT_WORKDIR_TAG
from ddtrace.internal.process_tags import normalize_tag_value
from ddtrace.internal.settings._config import config
from ddtrace.internal.settings.process_tags import process_tags_config as config
from tests.subprocesstest import run_in_subprocess
from tests.utils import TracerTestCase
from tests.utils import process_tag_reload
Expand Down Expand Up @@ -79,17 +79,17 @@ def test_normalize_tag(input_tag, expected):
class TestProcessTags(TracerTestCase):
def setUp(self):
super(TestProcessTags, self).setUp()
self._original_process_tags_enabled = config._process_tags_enabled
self._original_process_tags_enabled = config.enabled
self._original_process_tags = process_tags.process_tags

def tearDown(self):
config._process_tags_enabled = self._original_process_tags_enabled
config.enabled = self._original_process_tags_enabled
process_tags.process_tags = self._original_process_tags
super().tearDown()

@pytest.mark.snapshot
def test_process_tags_deactivated(self):
config._process_tags_enabled = False
config.enabled = False # type: ignore[assignment]
process_tag_reload()

with self.tracer.trace("test"):
Expand All @@ -98,7 +98,7 @@ def test_process_tags_deactivated(self):
@pytest.mark.snapshot
def test_process_tags_activated(self):
with patch("sys.argv", [TEST_SCRIPT_PATH]), patch("os.getcwd", return_value=TEST_WORKDIR_PATH):
config._process_tags_enabled = True
config.enabled = True # type: ignore[assignment]
process_tag_reload()

with self.tracer.trace("parent"):
Expand All @@ -108,7 +108,7 @@ def test_process_tags_activated(self):
@pytest.mark.snapshot
def test_process_tags_edge_case(self):
with patch("sys.argv", ["/test_script"]), patch("os.getcwd", return_value=TEST_WORKDIR_PATH):
config._process_tags_enabled = True
config.enabled = True # type: ignore[assignment]
process_tag_reload()

with self.tracer.trace("span"):
Expand All @@ -117,7 +117,7 @@ def test_process_tags_edge_case(self):
@pytest.mark.snapshot
def test_process_tags_error(self):
with patch("sys.argv", []), patch("os.getcwd", return_value=TEST_WORKDIR_PATH):
config._process_tags_enabled = True
config.enabled = True # type: ignore[assignment]

with self.override_global_config(dict(_telemetry_enabled=False)):
with patch("ddtrace.internal.process_tags.log") as mock_log:
Expand All @@ -137,7 +137,7 @@ def test_process_tags_error(self):
@run_in_subprocess(env_overrides=dict(DD_TRACE_PARTIAL_FLUSH_ENABLED="true", DD_TRACE_PARTIAL_FLUSH_MIN_SPANS="2"))
def test_process_tags_partial_flush(self):
with patch("sys.argv", [TEST_SCRIPT_PATH]), patch("os.getcwd", return_value=TEST_WORKDIR_PATH):
config._process_tags_enabled = True
config.enabled = True # type: ignore[assignment]
process_tag_reload()

with self.override_global_config(dict(_partial_flush_enabled=True, _partial_flush_min_spans=2)):
Expand Down
8 changes: 8 additions & 0 deletions tests/telemetry/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def test_get_application_with_values():
assert application["env"] == "staging"


@pytest.mark.subprocess(env={"DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED": "True"})
def test_get_application_with_process_tags():
from ddtrace.internal.telemetry.data import get_application

application = get_application("", "", "")
assert "process_tags" in application


def test_application_with_setenv(run_python_code_in_subprocess, monkeypatch):
"""
validates the return value of get_application when DD_SERVICE, DD_VERSION, and DD_ENV environment variables are set
Expand Down
Loading