agentleFS
FireTableFireTable/langgraph-app/.agents/skills/observability/SKILL.md

observability

Skill8 starsChanged 5 months agoMITView on GitHub

Adds tracing, telemetry, and observability to an assistant-ui backend. Use when wiring an AI SDK route handler (streamText/generateText, toUIMessageStreamResponse) to a tracing backend: Langfuse via OpenTelemetry (LangfuseSpanProcessor and NodeSDK in instrumentation.ts, experimental_telemetry isEnabled, propagateAttributes with traceName/userId/sessionId, langfuseSpanProcessor.forceFlush on serverless), LangSmith via wrapAISDK(ai) from langsmith/experimental/vercel (createLangSmithProviderOptions, awaitPendingTraceBatches), or Helicone via createOpenAI baseURL https://oai.helicone.ai/v1 with the Helicone-Auth header. Also covers rendering collected spans with @assistant-ui/react-o11y headless primitives (SpanResource, SpanPrimitive Root/Indent/CollapseToggle/StatusIndicator/TypeBadge/Name/Children, SpanByIndexProvider, SpanData/SpanState) mounted via useAui/AuiProvider from @assistant-ui/store. Use for missing or empty traces, edge vs nodejs runtime telemetry, serverless flush issues, or trace waterfalls.

  • Reads credentials
  • Installs packages

103 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use gitops, background-jobs and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • kcns008Skill

    gitops

    GitOps Agent (Flow) — manages ArgoCD applications, Helm charts, Kustomize overlays, deployment strategies (canary, blue-green, rolling), multi-cluster GitOps, and drift detection for Kubernetes and OpenShift clusters.

    Also in 5 projects that use this

  • YepAPISkill

    background-jobs

    Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

    Also in 5 projects that use this

  • Mushfiqur-Rahman-RobinSkill

    rag-systems

    Best practices for building Retrieval-Augmented Generation systems — chunking, embedding, hybrid retrieval, reranking, indexing, caching, evaluation, observability — plus a catalog of RAG patterns and when each applies.

    Also in 3 projects that use this

  • ffsshhttiikkSkill

    chaos-engineering

    Resilience testing through controlled experiments

    Also in 6 projects that use this

  • jholhewresSkill

    dora-metrics

    Calculate DORA metrics from git + deploy logs

    Also in 3 projects that use this

  • wpankSkill

    caching

    Caching strategies, invalidation, eviction policies, HTTP caching, distributed caching, and anti-patterns. Use when designing cache layers, choosing eviction policies, debugging stale data, or optimizing read-heavy workloads.

    Also in 6 projects that use this

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 85 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this openai instance with streamText as usual.

    line 129
  2. Very specific:

    Use the destructured methods from wrapAISDK(ai), not the originals from ai.

    line 180

“Common” is measured: kept by at least 6 in 10 of the 85 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

assistant-ui Observability

Always consult assistant-ui.com/llms.txt for the latest API.

Tracing and telemetry for an assistant-ui backend. Most of this is generic AI SDK telemetry; the assistant-ui specific part is the route handler and the @assistant-ui/react-o11y client primitives for rendering spans.

Contents

  • References
  • Where it plugs in
  • Provider routing
  • AI SDK telemetry (shared)
  • Helicone (proxy, no OTel)
  • Visualizing spans with react-o11y
  • Common Gotchas
  • Related Skills

References

  • ./references/langfuse.md -- Langfuse tracing
  • ./references/langsmith.md -- LangSmith tracing
  • ./references/helicone.md -- Helicone proxy
  • ./references/react-o11y.md -- @assistant-ui/react-o11y client primitives

Where it plugs in

Telemetry attaches to the server route that calls streamText/generateText, not to the React runtime. The frontend (useChatRuntime, Thread) is unchanged. react-o11y is a separate, optional client layer for drawing the trace waterfall in your own UI.

Thread (frontend) ──> /api/chat (streamText) ──> tracing backend
                                              └─> react-o11y (optional UI)

Provider routing

Langfuse   → OTel span processor + experimental_telemetry, propagateAttributes
LangSmith  → wrapAISDK(ai) wrapper, no OTel setup
Helicone   → proxy baseURL on the provider, no telemetry flag
react-o11y → client primitives to render spans you collected

AI SDK telemetry (shared)

Langfuse and any OTel backend reuse the AI SDK experimental_telemetry flag. Enable it per call:

import { openai } from "@ai-sdk/openai";
import { streamText, convertToModelMessages } from "ai";
import type { UIMessage } from "ai";

export async function POST(req: Request) {
  const { messages }: { messages: UIMessage[] } = await req.json();
  const result = streamText({
    model: openai("gpt-5.4-nano"),
    messages: await convertToModelMessages(messages),
    experimental_telemetry: { isEnabled: true },
  });
  return result.toUIMessageStreamResponse();
}

For Langfuse, register an OTel span processor in instrumentation.ts and wrap the call so traces carry userId/sessionId:

import { NodeSDK } from "@opentelemetry/sdk-node";
import { LangfuseSpanProcessor } from "@langfuse/otel";

export const langfuseSpanProcessor = new LangfuseSpanProcessor();

export async function register() {
  if (process.env.NEXT_RUNTIME !== "nodejs") return;
  const sdk = new NodeSDK({ spanProcessors: [langfuseSpanProcessor] });
  sdk.start();
}
import { propagateAttributes } from "@langfuse/tracing";

const result = await propagateAttributes(
  { traceName: "chat-completion", userId, sessionId },
  async () =>
    streamText({
      model: openai("gpt-5.4-nano"),
      messages: await convertToModelMessages(messages),
      experimental_telemetry: { isEnabled: true },
    }),
);

LangSmith skips OTel entirely; wrap the ai module instead. convertToModelMessages is not wrapped, so import it from ai directly:

import * as ai from "ai";
import { wrapAISDK } from "langsmith/experimental/vercel";
import { openai } from "@ai-sdk/openai";

const { streamText } = wrapAISDK(ai);

const result = streamText({
  model: openai("gpt-5.4-nano"),
  messages: await ai.convertToModelMessages(messages),
});
return result.toUIMessageStreamResponse();

See the per provider reference files for env vars, metadata tagging, and serverless flushing.

Helicone (proxy, no OTel)

Helicone needs no telemetry flag. Point the provider at the proxy baseURL and pass the auth header:

import { createOpenAI } from "@ai-sdk/openai";

const openai = createOpenAI({
  baseURL: "https://oai.helicone.ai/v1",
  headers: { "Helicone-Auth": `Bearer ${process.env.HELICONE_API_KEY}` },
});

Use this openai instance with streamText as usual; streaming, tools, and attachments are unchanged.

Visualizing spans with react-o11y

@assistant-ui/react-o11y gives headless primitives to render collected spans as a trace waterfall. Feed it SpanData[] (id, parentSpanId, name, type, status, startedAt, endedAt, latencyMs) via SpanResource, mount with useAui, and render SpanPrimitive parts.

npm install @assistant-ui/react-o11y
import { SpanResource, SpanPrimitive, type SpanData } from "@assistant-ui/react-o11y";
import { AuiProvider, useAui } from "@assistant-ui/store";

function SpanRow() {
  return (
    <SpanPrimitive.Root>
      <SpanPrimitive.Indent />
      <SpanPrimitive.CollapseToggle />
      <SpanPrimitive.StatusIndicator />
      <SpanPrimitive.TypeBadge />
      <SpanPrimitive.Name />
    </SpanPrimitive.Root>
  );
}

export function TraceView({ spans }: { spans: SpanData[] }) {
  const aui = useAui({ resource: SpanResource({ spans }) });
  return (
    <AuiProvider value={aui}>
      <SpanPrimitive.Children components={{ Span: SpanRow }} />
    </AuiProvider>
  );
}

SpanPrimitive.Children flattens the tree to a visible list and wraps each item in SpanByIndexProvider. Root exposes data-span-status, data-span-type, data-span-depth, and data-collapsed for styling. See react-o11y.md for the full part list and SpanState shape.

Common Gotchas

No traces on Vercel/Lambda

  • The function exits before OTel flushes its buffer. Langfuse: await langfuseSpanProcessor.forceFlush() before responding. LangSmith: await new Client().awaitPendingTraceBatches().

Langfuse traces empty

  • experimental_telemetry: { isEnabled: true } must be set on each streamText/generateText call.
  • The span processor only registers when process.env.NEXT_RUNTIME === "nodejs"; OTel does not run on the edge runtime.

LangSmith not tracing

  • Use the destructured methods from wrapAISDK(ai), not the originals from ai. LANGSMITH_TRACING=true must be set.

Helicone requests still hit OpenAI directly

  • Confirm requests go to oai.helicone.ai, not api.openai.com, and carry both Helicone-Auth and Authorization headers.

react-o11y renders nothing

  • Primitives must render inside AuiProvider; the resource mounts through useAui({ resource: SpanResource({ spans }) }).

Related Skills

  • /streaming - The route handler and stream response telemetry attaches to
  • /setup - Backend wiring (ai-sdk, custom-backend) where the route lives
  • /cloud - Persistence; pair userId/sessionId/threadId with trace attributes

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.