Skip to content

feat: Implement Request ID Tracing for Tool Execution Chains (#107)#287

Merged
adams813 merged 2 commits intobenelabs:mainfrom
TochukwuJustice:fix-request-id
May 3, 2026
Merged

feat: Implement Request ID Tracing for Tool Execution Chains (#107)#287
adams813 merged 2 commits intobenelabs:mainfrom
TochukwuJustice:fix-request-id

Conversation

@TochukwuJustice
Copy link
Copy Markdown
Contributor

closes #107
Summary of Changes:

Context Layer (src/logger.ts): Exported requestContext, a typed AsyncLocalStorage<{ requestId: string }>. Added a Pino mixin() that automatically injects request_id into every log entry emitted during a request — no additional code needed at any call site.
Tracing Middleware (src/index.ts): Wrapped each tool execution in requestContext.run(). A request_id is extracted from tool arguments if provided by the client; otherwise a cryptographically unique UUID is auto-generated via node:crypto.
Header Propagation (src/services/horizon.ts): Updated getHorizonServer() to read the active request context and forward X-Request-ID to every outgoing Stellar Horizon API call, enabling end-to-end tracing.
Unit Tests (tests/unit/tracing.test.ts): 4 tests covering context isolation, propagation, lifecycle, and concurrent request safety — all passing.
Reason for Changes: Complex multi-tool execution chains in MCP servers are difficult to debug without a consistent correlation ID. This implementation establishes a zero-overhead tracing layer that links logs, tool execution, and outgoing Stellar network requests under a single request_id.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 29, 2026

@TochukwuJustice Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@adams813
Copy link
Copy Markdown
Collaborator

adams813 commented May 1, 2026

Nice implementation, lgtm!

@TochukwuJustice
Copy link
Copy Markdown
Contributor Author

Nice implementation, lgtm!

thanks man.. please merge PRs

@adams813
Copy link
Copy Markdown
Collaborator

adams813 commented May 3, 2026

Nice Implementation, LGTM!

@adams813 adams813 merged commit 879c2d2 into benelabs:main May 3, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Request ID Tracing

2 participants