test(server-utils): Cover the Flue instrumentation - #24266
Draft
RulaKhaled wants to merge 4 commits into
Draft
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-base
branch
from
September 10, 2026 07:41
9fb3fcd to
d62f4f2
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-base
branch
from
September 11, 2026 06:13
d62f4f2 to
a0e8143
Compare
RulaKhaled
force-pushed
the
feat/flue-instrumentation-tests
branch
3 times, most recently
from
September 11, 2026 11:52
b4ad273 to
74f4654
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>
RulaKhaled
force-pushed
the
feat/flue-instrumentation-tests
branch
from
September 11, 2026 12:53
74f4654 to
cd565ee
Compare
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>
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