Skip to content

Commit d80c2ce

Browse files
juanjuxmabdinur
andauthored
fix(asm): add missing track tag to custom events tracking [backport #5365 to 1.10] (#5373)
Backport to 1.10 The `track_custom_event()` function was not setting the `appsec.events.<event name>.track` tag, which is required for the event tracking SDK. This PR fixes this. Signed-off-by: Juanjo Alvarez <[email protected]> (cherry picked from commit aced65e) ## 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] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [X] Change is maintainable (easy to change, telemetry, documentation). - [X] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines) are followed. - [X] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [X] Author is aware of the performance implications of this PR as reported in the benchmarks PR comment. ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer is aware of, and discussed the performance implications of this PR as reported in the benchmarks PR comment. --------- Signed-off-by: Juanjo Alvarez <[email protected]> Co-authored-by: Munir Abdinur <[email protected]>
1 parent b21623e commit d80c2ce

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

ddtrace/appsec/trace_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def track_custom_event(tracer, event_name, metadata):
122122
)
123123
return
124124

125+
span.set_tag_str("%s.%s.track" % (APPSEC.CUSTOM_EVENT_PREFIX, event_name), "true")
126+
125127
for k, v in six.iteritems(metadata):
126128
span.set_tag_str("%s.%s.%s" % (APPSEC.CUSTOM_EVENT_PREFIX, event_name, k), str(v))
127129
span.set_tag_str(constants.MANUAL_KEEP_KEY, "true")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
ASM: make ``track_custom_event()`` also set ``appsec.events.<custom_event>.track`` which was missing.

tests/appsec/test_appsec_trace_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,4 @@ def test_custom_event(self):
9999
root_span = self.tracer.current_root_span()
100100

101101
assert root_span.get_tag("%s.%s.foo" % (APPSEC.CUSTOM_EVENT_PREFIX, event)) == "bar"
102+
assert root_span.get_tag("%s.%s.track" % (APPSEC.CUSTOM_EVENT_PREFIX, event)) == "true"

0 commit comments

Comments
 (0)