Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ddtrace/appsec/_asm_request_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def finalise(self):
callbacks = GLOBAL_CALLBACKS.get(_CONTEXT_CALL, []) if env.must_call_globals else []
env.must_call_globals = False
if env is not None and env.callbacks is not None and env.callbacks.get(_CONTEXT_CALL):
callbacks += env.callbacks.get(_CONTEXT_CALL)
callbacks = callbacks + env.callbacks.get(_CONTEXT_CALL)
if callbacks:
if env is not None:
for function in callbacks:
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/fix_incident_25768-043ae458e46c9620.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
ASM: This fix resolves an issue with Flask instrumentation causing CPU leak with ASM,
API Security and Telemetry enabled.
19 changes: 19 additions & 0 deletions tests/appsec/contrib_appsec/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,25 @@ def test_multiple_service_name(self, interface):
else:
raise AssertionError("extra service not found")

def test_global_callback_list_length(self, interface):
from ddtrace.appsec import _asm_request_context

with override_global_config(
dict(
_asm_enabled=True,
_api_security_enabled=True,
_telemetry_enabled=True,
)
):
self.update_tracer(interface)
assert ddtrace.config._remote_config_enabled
for _ in range(20):
response = interface.client.get("/new_service/awesome_test")
assert self.status(response) == 200
assert self.body(response) == "awesome_test"
# only two global callbacks are expected for API Security and Nested Events
assert len(_asm_request_context.GLOBAL_CALLBACKS.get(_asm_request_context._CONTEXT_CALL, [])) == 2


@contextmanager
def test_tracer():
Expand Down