Skip to content

Commit

Permalink
chore(telemetry): add item for instrumentation config id (#8783)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Kyle-Verhoog committed May 2, 2024
1 parent 01fbf91 commit faedc35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ddtrace/internal/telemetry/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@ def _app_started_event(self, register_app_shutdown=True):
if register_app_shutdown:
atexit.register(self.app_shutdown)

inst_config_id_entry = ("instrumentation_config_id", "", "default")
if "DD_INSTRUMENTATION_CONFIG_ID" in os.environ:
inst_config_id_entry = (
"instrumentation_config_id",
os.environ["DD_INSTRUMENTATION_CONFIG_ID"],
"env_var",
)

self.add_configurations(
[
self._telemetry_entry("_trace_enabled"),
Expand All @@ -435,6 +443,7 @@ def _app_started_event(self, register_app_shutdown=True):
self._telemetry_entry("trace_http_header_tags"),
self._telemetry_entry("tags"),
self._telemetry_entry("_tracing_enabled"),
inst_config_id_entry,
(TELEMETRY_STARTUP_LOGS_ENABLED, config._startup_logs_enabled, "unknown"),
(TELEMETRY_DYNAMIC_INSTRUMENTATION_ENABLED, di_config.enabled, "unknown"),
(TELEMETRY_EXCEPTION_DEBUGGING_ENABLED, ed_config.enabled, "unknown"),
Expand Down
3 changes: 3 additions & 0 deletions tests/telemetry/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def test_app_started_event(telemetry_writer, test_agent_session, mock_time):
{"name": "logs_injection_enabled", "origin": "default", "value": "false"},
{"name": "trace_tags", "origin": "default", "value": ""},
{"name": "tracing_enabled", "origin": "default", "value": "true"},
{"name": "instrumentation_config_id", "origin": "default", "value": ""},
],
key=lambda x: x["name"],
),
Expand Down Expand Up @@ -229,6 +230,7 @@ def test_app_started_event_configuration_override(
env["DD_TRACE_WRITER_INTERVAL_SECONDS"] = "30"
env["DD_TRACE_WRITER_REUSE_CONNECTIONS"] = "True"
env["DD_TAGS"] = "team:apm,component:web"
env["DD_INSTRUMENTATION_CONFIG_ID"] = "abcedf123"
env[env_var] = value

file = tmpdir.join("moon_ears.json")
Expand Down Expand Up @@ -314,6 +316,7 @@ def test_app_started_event_configuration_override(
{"name": "trace_header_tags", "origin": "default", "value": ""},
{"name": "trace_tags", "origin": "env_var", "value": "team:apm,component:web"},
{"name": "tracing_enabled", "origin": "env_var", "value": "false"},
{"name": "instrumentation_config_id", "origin": "env_var", "value": "abcedf123"},
],
key=lambda x: x["name"],
)
Expand Down

0 comments on commit faedc35

Please sign in to comment.