logfire-instrumentation

Add Pydantic Logfire observability to application code — traces, logs, metrics, and AI/agent spans. Use when the user asks to add or configure Logfire, observability, tracing, logging, or monitoring; maximize useful telemetry; or understand what an app is doing. Supports Python, JavaScript/TypeScript, Rust, and major AI agent frameworks including Pydantic AI, OpenAI Agents SDK, Claude Agent SDK, LangChain, LangGraph, CrewAI, AutoGen, and Google ADK. For infrastructure-only monitoring (hosts, Docker, Kubernetes, databases, or cloud metrics with no app-code changes), use `logfire-infrastructure`. For evaluating AI/agent behavior against test datasets, use `logfire-evals`.

Install
npx skills add 'https://github.com/pydantic/logfire/tree/main/logfire-sdk/logfire/.agents/skills/logfire-instrumentation'
Download bundle ↓
main · 39d1eb4Scanned 2026-09-17

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗
View on GitHub
← Back to SKILL.md

JavaScript Framework Setup

This file is a compatibility index for older prompts that ask for the JS framework reference directly. For new instrumentation work, read project-detection.md first, then the runtime-specific reference.

Runtime Routing

Detected projectPrimary referenceRuntime package
Express, Fastify, Koa, Hono on Node, scripts, CLIs, workers outside edge runtimesnode-runtime.md@pydantic/logfire-node
Next.js server-side tracingnextjs.md@vercel/otel plus logfire for manual spans
React/Vite/browser tracingreact-browser.md@pydantic/logfire-browser
Cloudflare Workerscloudflare-and-deno.md@pydantic/logfire-cf-workers plus logfire
Denocloudflare-and-deno.mdDeno OpenTelemetry plus npm:logfire
Vercel AI SDKai-sdk.mdDepends on Node or Next.js setup

Current Defaults

  • Use node --import ./instrumentation.js for modern Node ESM preload. Use --require only for CommonJS.
  • Browser code sends directly with a restricted public frontend application token and its regional base URL through configureFrontend({ baseUrl, token }) (@pydantic/logfire-browser 0.21.0 or later). Never expose LOGFIRE_TOKEN, OTEL_EXPORTER_OTLP_HEADERS, or another ordinary write token in a browser bundle.
  • Next.js server-side tracing should use @vercel/otel; do not use @pydantic/logfire-node as the primary Next server setup unless the app has a separate custom Node server.
  • Cloudflare Workers wrap the exported handler with instrument() from @pydantic/logfire-cf-workers; import manual spans/logs from logfire.
Referenced from SKILL.md