Skip to content

Commit

Permalink
fix(agent.host): Missing spans when handling forked processes.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pvital committed Nov 8, 2023
1 parent 6e22d34 commit 4e50c63
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion instana/agent/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion instana/collector/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4e50c63

Please sign in to comment.