Skip to content

Commit faedc35

Browse files
authored
chore(telemetry): add item for instrumentation config id (#8783)
When enabling library injection remotely through the UI, we'd like to show which services have been instrumented as a result. To do this we are proposing to submit the remote configuration ID that was used to instrument the service. [](https://datadoghq.atlassian.net/browse/APMON-887) ## Checklist - [x] Change(s) are motivated and described in the PR description - [x] Testing strategy is described if automated tests are not included in the PR - [x] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)) - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. - [x] If change touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
1 parent 01fbf91 commit faedc35

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

ddtrace/internal/telemetry/writer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,14 @@ def _app_started_event(self, register_app_shutdown=True):
422422
if register_app_shutdown:
423423
atexit.register(self.app_shutdown)
424424

425+
inst_config_id_entry = ("instrumentation_config_id", "", "default")
426+
if "DD_INSTRUMENTATION_CONFIG_ID" in os.environ:
427+
inst_config_id_entry = (
428+
"instrumentation_config_id",
429+
os.environ["DD_INSTRUMENTATION_CONFIG_ID"],
430+
"env_var",
431+
)
432+
425433
self.add_configurations(
426434
[
427435
self._telemetry_entry("_trace_enabled"),
@@ -435,6 +443,7 @@ def _app_started_event(self, register_app_shutdown=True):
435443
self._telemetry_entry("trace_http_header_tags"),
436444
self._telemetry_entry("tags"),
437445
self._telemetry_entry("_tracing_enabled"),
446+
inst_config_id_entry,
438447
(TELEMETRY_STARTUP_LOGS_ENABLED, config._startup_logs_enabled, "unknown"),
439448
(TELEMETRY_DYNAMIC_INSTRUMENTATION_ENABLED, di_config.enabled, "unknown"),
440449
(TELEMETRY_EXCEPTION_DEBUGGING_ENABLED, ed_config.enabled, "unknown"),

tests/telemetry/test_writer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def test_app_started_event(telemetry_writer, test_agent_session, mock_time):
146146
{"name": "logs_injection_enabled", "origin": "default", "value": "false"},
147147
{"name": "trace_tags", "origin": "default", "value": ""},
148148
{"name": "tracing_enabled", "origin": "default", "value": "true"},
149+
{"name": "instrumentation_config_id", "origin": "default", "value": ""},
149150
],
150151
key=lambda x: x["name"],
151152
),
@@ -229,6 +230,7 @@ def test_app_started_event_configuration_override(
229230
env["DD_TRACE_WRITER_INTERVAL_SECONDS"] = "30"
230231
env["DD_TRACE_WRITER_REUSE_CONNECTIONS"] = "True"
231232
env["DD_TAGS"] = "team:apm,component:web"
233+
env["DD_INSTRUMENTATION_CONFIG_ID"] = "abcedf123"
232234
env[env_var] = value
233235

234236
file = tmpdir.join("moon_ears.json")
@@ -314,6 +316,7 @@ def test_app_started_event_configuration_override(
314316
{"name": "trace_header_tags", "origin": "default", "value": ""},
315317
{"name": "trace_tags", "origin": "env_var", "value": "team:apm,component:web"},
316318
{"name": "tracing_enabled", "origin": "env_var", "value": "false"},
319+
{"name": "instrumentation_config_id", "origin": "env_var", "value": "abcedf123"},
317320
],
318321
key=lambda x: x["name"],
319322
)

0 commit comments

Comments
 (0)