pydantic/logfire-js
OpenTelemetry SDK for JavaScript observability and agent evaluation
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Logfire JS is a TypeScript SDK, not an agent runtime. Its pnpm workspace separates the shared logfire API from runtime-specific integration packages. @pydantic/logfire-node provides configure() for Node.js, @pydantic/logfire-cf-workers wraps a Worker handler with instrument(), and @pydantic/logfire-browser is released separately. OpenTelemetry is the protocol boundary for traces, metrics, and logs; Vercel and Deno can use their existing exporters.
Evaluation lives at logfire/evals. Dataset.evaluate() runs a task for each Case, applies case-specific evaluators before shared ones, then runs report evaluators once all cases complete. The resulting EvaluationReport contains results, failures, aggregates, and analyses. Online evaluation takes a different path: withOnlineEvaluation() wraps an async task and evaluates sampled calls in the background, emitting results as OpenTelemetry log events and optionally sending them to in-process sinks.
Key Capabilities & Differentiators
The SDK combines telemetry with code-first assessment of application functions, including LLM and agent tasks. Cases can be authored in TypeScript or loaded from YAML/JSON using the serialized dataset format shared with Python pydantic-evals. Built-in checks cover expected outputs, containment, runtime types, duration, and span matching through SpanQuery. LLMJudge accepts a callback per evaluator or a default registered through setDefaultJudge(); it does not bundle a client or prescribe a provider or model family.
Custom evaluators can return booleans, numeric scores, labels, explained scalar values, or multiple named results. An exception is recorded against its case rather than stopping the experiment. Report evaluators add confusion matrices, precision-recall analysis, ROC AUC, and Kolmogorov–Smirnov analysis to report.analyses; when Logfire is configured, those analyses are also attached to the experiment span. The Logfire backend provides SQL querying, while the offline runner returns a report directly to the caller.
Trade-offs & Limitations
Compared with wiring OpenTelemetry directly to an existing backend, Logfire JS adds runtime setup helpers, evaluation primitives, and a way to inspect evaluation results alongside traces in Logfire. Direct OpenTelemetry remains a better fit when standard signals are enough and the team already owns its collection and analytics stack. Although the SDK is MIT-licensed, the Logfire ingestion and dashboard server is closed source and is not shipped here. OpenTelemetry compatibility does not make Logfire's SQL interface or evaluation views portable to a different backend.
The SDK also leaves model selection, credentials, retries, and judge cost to the application rather than bundling a model client. Online evaluation is sampled and runs in the background, but still consumes resources: budget for telemetry volume, concurrent evaluations, and any judge API calls. No accelerator is needed for ordinary instrumentation or deterministic checks; a local model behind a custom judge changes that sizing. Before enabling export, review which task attributes and evaluation results may leave the environment.
Hardware & Deployment Guide
The root manifest pins Node.js 24 for development of the pnpm workspace; that does not establish a minimum for every published package. For Node.js applications, install @pydantic/logfire-node, supply a write token, and call configure() before loading modules you want automatically instrumented. Add logfire directly when importing logfire/evals. Await shutdown() in short-lived Node.js scripts. Offline experiments can run in process without exporting to Logfire.
Cloudflare Workers requires nodejs_compat and uses LOGFIRE_TOKEN, which can be set as a Wrangler secret in production. Next.js on Vercel can use @vercel/otel with the Logfire OTLP trace and metric endpoints and an authorization header; browser-side fetch requires separate instrumentation. Deno can export through its native OpenTelemetry support. Browser 0.41.6 and Workers 2.3.3 are patch releases that update the shared logfire dependency to 0.26.5; they do not establish new runtime capabilities.
@vercel/otel and Deno's native OpenTelemetry support.logfire/evals mirrors the Python pydantic-evals data model and serialized YAML/JSON dataset format.HasMatchingSpan applies a SpanQuery to task instrumentation, while MaxDuration checks execution time.gen_ai.evaluation.result OpenTelemetry log events and can forward results to in-process sinks.TypeScript teams that want runtime traces, pre-release evaluation of application or agent tasks, and sampled production checks without adopting an agent runtime.
You need a fully open-source, self-hostable ingestion and dashboard stack, a bundled judge model, or only standard OpenTelemetry export to an existing backend.
Quick Start & Installation
mkdir test-logfire-js cd test-logfire-js npm init -y es6 # creates package.json with `type: module` npm install @pydantic/logfire-node
Comparison vs. Top Agents & Frameworks Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| logfire-js ★ | 72 | — | TypeScript | MIT | OpenTelemetry SDK for JavaScript observability and agent evaluation |
| ag-ui | 22.6k | +611 | TypeScript | MIT | A typed event protocol and SDKs that connect agent backends to interactive apps |
| ruflo | 82.8k | +342 | TypeScript | MIT | A TypeScript orchestration layer for coding agents, with shared memory and MCP |
| browser-use | 122.7k | +477 | Python | MIT | Python REPL and CDP for adaptive browser automation |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/pydantic/logfire-js.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about logfire-js
Where should Logfire initialization sit in a Node.js application?
@pydantic/logfire-node and call configure() before importing Express so automatic instrumentation can initialize first. Declare logfire as a direct dependency if you import logfire/evals. For one-shot scripts, await shutdown() before exiting.Does the SDK need a GPU, and what drives runtime overhead?
Can we use the SDK commercially and self-host the complete Logfire stack?
When is Logfire JS a better fit than integrating OpenTelemetry directly?
Dataset.evaluate() returns a report in process, so offline checks do not require the dashboard.Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy