Flue (tracing)
Flue is a TypeScript agent harness framework for autonomous agents and AI workflows. Use @respan/instrumentation-flue to subscribe to Flue runtime events and emit canonical Respan spans.
Set up Respan
Create an account at platform.respan.ai and grab an API key .
Paste this into your coding agent:
Help me set up Respan tracing with the Flue integration.
Follow https://www.respan.ai/docs/integrations/flue.mdSetup
Install packages
npm install @flue/runtime @respan/respan @respan/tracing @respan/instrumentation-flueSet environment variables
export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"Initialize Respan before Flue handles activity
import * as FlueRuntime from "@flue/runtime";
import { Respan } from "@respan/respan";
import { FlueInstrumentor } from "@respan/instrumentation-flue";
const respan = new Respan({
apiKey: process.env.RESPAN_API_KEY,
baseURL: process.env.RESPAN_BASE_URL,
appName: "flue-tracing",
instrumentations: [
new FlueInstrumentor({
runtimeModule: FlueRuntime,
workflowName: "Flue App.workflow",
}),
],
});
await respan.initialize();Register the instrumentor once during application startup, before Flue handles workflow or agent activity.
Run Flue activity inside a Respan workflow
await respan.propagateAttributes(
{
trace_group_identifier: "Flue App.workflow",
metadata: {
service: "agent-runtime",
framework: "flue",
},
},
async () => {
await respan.withWorkflow({ name: "Flue App" }, async () => {
// Run your Flue agent, workflow, or runtime activity here.
});
}
);
View your trace
Open the Traces page to see Flue workflow runs, agent sessions, model turns, tool executions, tasks, shell operations, compaction events, and structured logs.
Captured data
| Data | Description |
|---|---|
| Workflow runs | Flue run lifecycle events, inputs, outputs, duration, and errors. |
| Direct agents | Agent lifecycle events for direct Flue agent sessions. |
| Model turns | Model request, response, usage, provider, API type, and reasoning metadata. |
| Tools | Tool names, arguments, outputs, durations, and errors. |
| Tasks | Delegated task prompts, agents, results, durations, and failures. |
| Shell operations | Shell command operations and command failure details. |
| Compaction | Context compaction metadata including before/after message counts. |
| Structured logs | Flue application logs emitted through the runtime context. |
Attributes
Use Respan attributes to group Flue runs by user, trace group, or deployment.
await respan.propagateAttributes(
{
customer_identifier: "user_123",
thread_identifier: "flue-session-abc",
trace_group_identifier: "Support Agent.workflow",
metadata: {
environment: "production",
channel: "support",
},
},
async () => {
await respan.withWorkflow({ name: "Support Agent" }, runFlueAgent);
}
);| Attribute | Type | Description |
|---|---|---|
customer_identifier | string | Identifies the end user in Respan analytics. |
thread_identifier | string | Groups related Flue activity into a session. |
trace_group_identifier | string | Groups related spans into a named trace group. |
metadata | object | Custom key-value pairs attached to spans. |
Notes
@respan/instrumentation-fluelistens to Flue’s runtimeobserve()event stream.- Pass
runtimeModulewhen your app imports@flue/runtimedirectly. This ensures the instrumentor observes the same runtime module instance your application uses. - The TypeScript examples are deterministic and emit representative Flue workflow, agent, model-turn, tool, task, compaction, log, and recovery events without calling an external LLM provider.