From f7ebb549b0d17cbacad9cd81c95693d0adb61a8b Mon Sep 17 00:00:00 2001 From: "Gabriele N. Tornetta" Date: Thu, 18 May 2023 15:10:18 +0100 Subject: [PATCH] chore(debugging): correct probe injection logging The logic for the debug logging of injected probes was incorrect and could have caused the same log message to be emitted multiple times. In other cases the information emitted would have resulted inaccurate, particularly when a line probe failed to inject. --- ddtrace/debugging/_debugger.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ddtrace/debugging/_debugger.py b/ddtrace/debugging/_debugger.py index 97774751bc7..6f6b7d16034 100644 --- a/ddtrace/debugging/_debugger.py +++ b/ddtrace/debugging/_debugger.py @@ -425,13 +425,21 @@ def _probe_injection_hook(self, module): failed = self._function_store.inject_hooks( function, [(self._dd_debugger_hook, cast(LineProbe, probe).line, probe) for probe in probes] ) + for probe in probes: if probe.probe_id in failed: self._probe_registry.set_error(probe, "Failed to inject") - log.error("Failed to inject %r", probe) else: self._probe_registry.set_installed(probe) - log.debug("Injected probes %r in %r", [probe.probe_id for probe in probes], function) + + if failed: + log.error("Failed to inject probes %r", failed) + + log.debug( + "Injected probes %r in %r", + [probe.probe_id for probe in probes if probe.probe_id not in failed], + function, + ) def _inject_probes(self, probes): # type: (List[LineProbe]) -> None