Skip to content

test(server-utils): Cover the Flue instrumentation - #24266

Draft
RulaKhaled wants to merge 4 commits into
feat/flue-instrumentation-basefrom
feat/flue-instrumentation-tests
Draft

test(server-utils): Cover the Flue instrumentation#24266
RulaKhaled wants to merge 4 commits into
feat/flue-instrumentation-basefrom
feat/flue-instrumentation-tests

Conversation

@RulaKhaled

@RulaKhaled RulaKhaled commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

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/recordOutputs gating, trace continuation from a replayed traceparent, concurrent and delegated (subagent) runs, the provider-skip lifecycle, and dispose.

Integration: drives an agent through a tool call and asserts the full invoke_agentchat / execute_tool hierarchy, including that tool spans are siblings of chat under the agent invocation rather than children — matching how Flue's own OpenTelemetry adapter projects them.

The scenario uses pi-ai's built-in faux provider rather than a mock HTTP server, so responses are scripted in-process and no provider key is needed. It is ESM only — @flue/runtime has no require export condition, so the cjs mode returns early — and @flue/runtime is installed per-suite because its engines.node >= 22.19 would break yarn install on the Node 20 lane. Guarded by conditionalTest({ 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 trackSpan that has since been removed.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.81 kB added added
@sentry/browser - with treeshaking flags 27.12 kB added added
@sentry/browser - with treeshaking flags tracing without tracing 27.01 kB added added
@sentry/browser (incl. Tracing) 49.22 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 49.22 kB added added
@sentry/browser (incl. Tracing, Profiling) 52.15 kB added added
@sentry/browser (incl. Tracing, Replay) 88.76 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.94 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 93.44 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 106.38 kB added added
@sentry/browser (incl. Feedback) 46.3 kB added added
@sentry/browser (incl. sendFeedback) 33.87 kB added added
@sentry/browser (incl. FeedbackAsync) 38.99 kB added added
@sentry/browser (incl. Metrics) 29.84 kB added added
@sentry/browser (incl. Logs) 30.1 kB added added
@sentry/browser (incl. Metrics & Logs) 30.78 kB added added
@sentry/react 30.57 kB added added
@sentry/react (incl. Tracing) 51.57 kB added added
@sentry/vue 36.07 kB added added
@sentry/vue (incl. Tracing) 51.49 kB added added
@sentry/svelte 28.85 kB added added
CDN Bundle 30.56 kB added added
CDN Bundle (incl. Tracing) 49.76 kB added added
CDN Bundle (incl. Logs, Metrics) 32.83 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 51.7 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 73.48 kB added added
CDN Bundle (incl. Tracing, Replay) 87.28 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 89.2 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 93.21 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 95.22 kB added added
CDN Bundle - uncompressed 90.47 kB added added
CDN Bundle (incl. Tracing) - uncompressed 148.17 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.04 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 154.13 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.3 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.76 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.71 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.46 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 287.4 kB added added
@sentry/nextjs (client) 54.03 kB added added
@sentry/sveltekit (client) 49.68 kB added added
@sentry/core/server 36.99 kB added added
@sentry/core/browser 13.55 kB added added
@sentry/node 127.9 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.61 kB added added
@sentry/node - without tracing 88.73 kB added added
@sentry/node - without channel injection 107.15 kB added added
@sentry/aws-serverless 97.12 kB added added
@sentry/cloudflare (withSentry) - minified 202.05 kB added added
@sentry/cloudflare (withSentry) 502.91 kB added added

@RulaKhaled
RulaKhaled force-pushed the feat/flue-instrumentation-tests branch from 89239da to deb3330 Compare September 9, 2026 19:00
@RulaKhaled
RulaKhaled force-pushed the feat/flue-instrumentation-tests branch from deb3330 to bdda8e5 Compare September 9, 2026 19:08
@RulaKhaled
RulaKhaled force-pushed the feat/flue-instrumentation-base branch from 9fb3fcd to d62f4f2 Compare September 10, 2026 07:41
@RulaKhaled
RulaKhaled force-pushed the feat/flue-instrumentation-tests branch from bdda8e5 to 612798a Compare September 10, 2026 07:41
@RulaKhaled
RulaKhaled force-pushed the feat/flue-instrumentation-base branch from d62f4f2 to a0e8143 Compare September 11, 2026 06:13
@RulaKhaled
RulaKhaled force-pushed the feat/flue-instrumentation-tests branch 3 times, most recently from b4ad273 to 74f4654 Compare September 11, 2026 11:52
RulaKhaled and others added 3 commits September 11, 2026 14:52
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
RulaKhaled force-pushed the feat/flue-instrumentation-tests branch from 74f4654 to cd565ee Compare September 11, 2026 12:53
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>
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.

1 participant