test(server-utils): Cover the Flue instrumentation - #24266
Open
RulaKhaled wants to merge 9 commits into
Open
Conversation
Contributor
size-limit report 📦
|
RulaKhaled
force-pushed
the
feat/flue-instrumentation-tests
branch
from
September 9, 2026 19:00
89239da to
deb3330
Compare
RulaKhaled
force-pushed
the
feat/flue-instrumentation-tests
branch
from
September 9, 2026 19:08
deb3330 to
bdda8e5
Compare
RulaKhaled
force-pushed
the
feat/flue-instrumentation-tests
branch
from
September 10, 2026 07:41
bdda8e5 to
612798a
Compare
RulaKhaled
force-pushed
the
feat/flue-instrumentation-tests
branch
4 times, most recently
from
September 11, 2026 12:53
74f4654 to
cd565ee
Compare
RulaKhaled
marked this pull request as ready for review
September 14, 2026 07:46
RulaKhaled
requested review from
JPeer264 and
mydea
and removed request for
a team
September 14, 2026 07:46
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d69cb28. Configure here.
RulaKhaled
force-pushed
the
feat/flue-instrumentation-tests
branch
from
September 14, 2026 07:50
d69cb28 to
a7e44b7
Compare
RulaKhaled
added this pull request to stack #24376
September 14, 2026 13:33
RulaKhaled
force-pushed
the
feat/flue-instrumentation-tests
branch
2 times, most recently
from
September 14, 2026 13:53
965a470 to
ace67d3
Compare
RulaKhaled
force-pushed
the
feat/flue-instrumentation-tests
branch
from
September 14, 2026 14:27
ace67d3 to
da37aa7
Compare
Unit tests over `createFlueInstrumentation` for the span shapes, the conversation id lifted off the re-entered agent operation, the usage/cost mapping, the all-zero-usage guard on failed turns, tool spans, content recording and its `recordInputs`/`recordOutputs` gating, and dispose. The integration test drives a real agent through a tool call using `pi-ai`'s `faux` provider, so the run is deterministic and needs no provider key or mock server. ESM only: `@flue/runtime` has no `require` export condition, and it is installed per-suite because its `engines.node >= 22.19` would break `yarn install` on the Node 20 CI matrix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Concurrent agent runs, subagent delegation (adopted from Isaac's repro, moved into the suite and asserted through a helper so a span-order assumption cannot creep back), the agent name arriving via the observations, trace continuation from the replayed traceparent, the provider skip applying on first use and re-applying after a registry reset, the recording options following the current client, and the conventional request attributes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both tests fail against the previous implementation: the first leaves `openai` registered before the run so the old first-entry-only guard short-circuits, and the second overflows the turn tracker to prove the evicted span is ended rather than dropped unsent. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The `model` and `tool` interceptor branches open no span; they make the span `observe` already opened active so the provider's HTTP call and the tool's own work nest inside it. Deleting both branches left all 28 tests green, and the e2e does not reach it either: its parent assertions come from the observation stream firing inside the agent operation, and nothing in that scenario opens a span inside a tool or model operation. Each case fails when its own branch is removed, and neither fails for the other's. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both cases passed vacuously. `not.toBe(TRACE_ID)` on the malformed carrier also held when no agent span was opened at all, since `undefined` is not the carrier's id either; suppressing span creation entirely failed nine other tests and left that one green. And the active-trace case never checked the span landed on the surrounding request's trace, so continuing an unrelated new trace passed too. Now the first asserts a well-formed trace id, and the second asserts the agent span carries the `incoming request` span's own trace id. Dropping the `!getActiveSpan()` guard fails the second. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Fails without the capture: the span is still errored, so only the error event distinguishes the two. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Guards the concern raised on the Mastra error-capture PR: if a second capture path is added, or the error starts reaching the global handlers, this fails. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
RulaKhaled
force-pushed
the
feat/flue-instrumentation-tests
branch
from
September 14, 2026 20:04
da37aa7 to
354d0e9
Compare
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.

Stacked on #24265 — review that first; this diff is tests only.
Unit (28 cases): span shapes and ops, the conversation id lifted off the re-entered agent operation, the usage/cost mapping, the all-zero-usage guard on failed turns, tool spans and their error status, content recording with its
recordInputs/recordOutputsgating, trace continuation from a replayedtraceparent, concurrent and delegated (subagent) runs, the provider-skip lifecycle, and dispose.Integration: drives an agent through a tool call and asserts the full
invoke_agent→chat/execute_toolhierarchy, including that tool spans are siblings ofchatunder the agent invocation rather than children — matching how Flue's own OpenTelemetry adapter projects them.The scenario uses
pi-ai's built-infauxprovider rather than a mock HTTP server, so responses are scripted in-process and no provider key is needed. It is ESM only —@flue/runtimehas norequireexport condition, so thecjsmode returns early — and@flue/runtimeis installed per-suite because itsengines.node >= 22.19would breakyarn installon the Node 20 lane. Guarded byconditionalTest({ min: 22 }), so it skips on the repo's default Node 20; verified on Node 24.Both suites were mutation-tested rather than just run green: reverting the zero-usage guard, the conversation-id lift, the tool-span handling, the turn-tracker cap and the provider-skip guard each produced a failure. One test passed vacuously on the first attempt and was fixed; another was written against a branch that turned out to be unreachable, which surfaced dead code in
trackSpanthat has since been removed.🤖 Generated with Claude Code