Implement BatchCommand: send all spans per request as a single wire message#326
Open
jrothrock wants to merge 4 commits into
Open
Implement BatchCommand: send all spans per request as a single wire message#326jrothrock wants to merge 4 commits into
jrothrock wants to merge 4 commits into
Conversation
The core-agent is now launched with --daemonize true so the binary forks itself into a true daemon. No PID is retained by the worker. Fixes two related cluster bugs: 1. Always-spawns bug: start() now returns early when peerRunning() is true instead of calling startProcess() unconditionally. Each worker that starts after the first simply connects to the already- running daemon. 2. Cluster-shutdown bug (issue #117): stopProcess() is now a no-op. Workers can no longer kill the shared core-agent when shutting down or crashing, which previously took down Scout for all other workers in the cluster until a replacement was spawned. This mirrors how the Python agent handles the core-agent lifecycle: launch it, forget the PID, let the daemon manage itself. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… instantly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rker-owned stopProcess() is now a no-op; no worker can kill the shared daemon. allowShutdown had no documented behavior and no remaining effect. Stripped from ScoutConfiguration type and all test callsites. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…essage
Instead of sending StartRequest, StartSpan, TagSpan, StopSpan, TagRequest,
and FinishRequest individually over the socket, ScoutRequest.send() now
assembles all commands for a request into a single BatchCommand message and
sends it in one write. This matches the Python agent's wire format and reduces
N round-trips to the core-agent to one per request.
- V1BatchCommand request class wraps a commands array into {"BatchCommand": {...}}
- V1BatchCommandResponse parses the agent's acknowledgement
- ScoutSpan.buildCommands() recursively collects StartSpan, child spans,
TagSpan, and StopSpan for a span tree
- ScoutRequest.send() replaced with batch assembly path; emits RequestSent
after the single BatchCommand response is received
- e2e test verifies exactly one BatchCommand is sent per transaction and that
no standalone StartRequest/FinishRequest/Span messages appear
Closes #122
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BatchCommandmessage and sent in a single write to the core-agent socket, matching the Python agent's wire formatV1BatchCommandrequest/response classes added;ScoutSpan.buildCommands()recursively builds the flat command list for a span tree;ScoutRequest.send()replaces the individual-send chain with batch assemblyWire format produced
{ "BatchCommand": { "commands": [ { "StartRequest": { "request_id": "req-...", "timestamp": "..." } }, { "TagRequest": { "request_id": "req-...", "tag": "path", "value": "/" } }, { "StartSpan": { "request_id": "req-...", "span_id": "span-...", "operation": "Controller/home" } }, { "TagSpan": { "span_id": "span-...", "tag": "db.statement", "value": "SELECT 1" } }, { "StopSpan": { "span_id": "span-..." } }, { "FinishRequest":{ "request_id": "req-..." } } ] } }Test plan
"Request with spans is sent as a single BatchCommand wire message"totest/scout/index.e2e.tsBatchCommandmessage is received by the mock agent🤖 Generated with Claude Code