Skip to content

Commit 1c2419e

Browse files
authored
chore(debugging): correct probe injection logging (#5895)
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.
1 parent 08e3965 commit 1c2419e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ddtrace/debugging/_debugger.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,19 +443,23 @@ def _probe_injection_hook(self, module):
443443
failed = self._function_store.inject_hooks(
444444
function, [(self._dd_debugger_hook, cast(LineProbe, probe).line, probe) for probe in probes]
445445
)
446+
446447
for probe in probes:
447448
if probe.probe_id in failed:
448449
self._probe_registry.set_error(probe, "Failed to inject")
449-
log.error("[%s][P: %s] Failed to inject %r", os.getpid(), os.getppid(), probe)
450450
else:
451451
self._probe_registry.set_installed(probe)
452-
log.debug(
453-
"[%s][P: %s] Injected probes %r in %r",
454-
os.getpid(),
455-
os.getppid(),
456-
[probe.probe_id for probe in probes],
457-
function,
458-
)
452+
453+
if failed:
454+
log.error("[%s][P: %s] Failed to inject probes %r", os.getpid(), os.getppid(), failed)
455+
456+
log.debug(
457+
"[%s][P: %s] Injected probes %r in %r",
458+
os.getpid(),
459+
os.getppid(),
460+
[probe.probe_id for probe in probes if probe.probe_id not in failed],
461+
function,
462+
)
459463

460464
def _inject_probes(self, probes):
461465
# type: (List[LineProbe]) -> None

0 commit comments

Comments
 (0)