From 4e50c63c932b72ab422cd652d81a5aee030e1de3 Mon Sep 17 00:00:00 2001 From: Paulo Vital Date: Tue, 17 Oct 2023 21:41:29 +0200 Subject: [PATCH] fix(agent.host): Missing spans when handling forked processes. In multithreaded applications (services), only the first or master process is announced to the Agent when the service starts, but if a not announced forked process handles the (HTTP) ENTRY requests and it contains one or more EXIT spans created during the first request, those EXIT spans are missed and not reported. This fix returns True when agent.host.can_send() method is called and detects that the current process is a fork and has finished the announcement process to the Agent with a valid FSM state. Signed-off-by: Paulo Vital --- instana/agent/host.py | 1 - instana/collector/base.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/instana/agent/host.py b/instana/agent/host.py index 0dbbf4c00..c60f739f9 100644 --- a/instana/agent/host.py +++ b/instana/agent/host.py @@ -115,7 +115,6 @@ def can_send(self): self._boot_pid = current_pid logger.debug("Fork detected; Handling like a pro...") self.handle_fork() - return False if self.machine.fsm.current in ["wait4init", "good2go"]: return True diff --git a/instana/collector/base.py b/instana/collector/base.py index 318ec3159..af12317d8 100644 --- a/instana/collector/base.py +++ b/instana/collector/base.py @@ -115,9 +115,9 @@ def shutdown(self, report_final=True): e.g. If the host agent disappeared, we won't be able to report final data. @return: None """ - logger.debug("Collector.shutdown: Reporting final data.") self.thread_shutdown.set() if report_final is True: + logger.debug("Collector.shutdown: Reporting final data.") self.prepare_and_report_data() self.started = False