Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/rename-logfire-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"logfire": minor
---

BREAKING CHANGE: Package renamed from `@pydantic/logfire-api` to `logfire`.

This change makes the core API package easier to use with a simpler, unscoped name.

**Migration Guide**:

- Update package.json: Change `"@pydantic/logfire-api"` to `"logfire"`
- Update imports: Change `from '@pydantic/logfire-api'` to `from 'logfire'`
- Run `npm install` to update lockfiles

The package functionality remains identical. This is purely a naming change.

**Why this change?**
The core API package is used across all runtimes (Node, browser, Cloudflare Workers) and deserves the simpler package name. The Node.js-specific SDK with auto-instrumentation is now `@pydantic/logfire-node`.
18 changes: 18 additions & 0 deletions .changeset/rename-logfire-node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"@pydantic/logfire-node": minor
---

BREAKING CHANGE: Package renamed from `logfire` to `@pydantic/logfire-node`.

This change clarifies that this package is the Node.js-specific SDK with OpenTelemetry auto-instrumentation.

**Migration Guide**:

- Update package.json: Change `"logfire"` to `"@pydantic/logfire-node"`
- Update imports: Change `from 'logfire'` to `from '@pydantic/logfire-node'`
- Run `npm install` to update lockfiles

The package functionality remains identical. This is purely a naming change.

**Why this change?**
The core API package (now simply called `logfire`) is used across all runtimes. The Node.js SDK with auto-instrumentation is a more specialized package and should have a scoped, descriptive name.
8 changes: 7 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
"WebSearch",
"Bash(npm run build)",
"Bash(npm run build:*)",
"Bash(npx changeset:*)"
"Bash(npx changeset:*)",
"Skill(prp-workflow)",
"Bash(tree:*)",
"Bash(git mv:*)",
"Bash(npm install)",
"Bash(npm run test:*)",
"Bash(npm run ci:*)"
],
"deny": [],
"ask": []
Expand Down
20 changes: 10 additions & 10 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ This is a monorepo for the **Pydantic Logfire JavaScript SDK** - an observabilit

This is an **npm workspace monorepo** managed with **Turborepo**:

- `packages/logfire` - Main Node.js SDK with automatic OpenTelemetry instrumentation
- `packages/logfire-api` - Core API package that can be used standalone for manual tracing (no auto-instrumentation)
- `packages/logfire-node` - Node.js SDK with automatic OpenTelemetry instrumentation
- `packages/logfire-api` - Core API package (published as `logfire`) that can be used standalone for manual tracing (no auto-instrumentation)
- `packages/logfire-cf-workers` - Cloudflare Workers integration
- `packages/logfire-browser` - Browser/web SDK
- `packages/tooling-config` - Shared build and linting configuration
Expand All @@ -21,21 +21,21 @@ This is an **npm workspace monorepo** managed with **Turborepo**:

### Package Relationships

- `logfire-api` is the base package that provides the core tracing API (`span`, `info`, `debug`, `error`, etc.) - it wraps OpenTelemetry's trace API with convenience methods
- `logfire` (Node.js SDK) depends on `logfire-api` and adds automatic instrumentation via `@opentelemetry/auto-instrumentations-node`
- `logfire-cf-workers` depends on `logfire-api` and adds Cloudflare Workers-specific instrumentation
- `logfire-browser` depends on `logfire-api` and adds browser-specific instrumentation
- `logfire` (published from `packages/logfire-api`) is the base package that provides the core tracing API (`span`, `info`, `debug`, `error`, etc.) - it wraps OpenTelemetry's trace API with convenience methods
- `@pydantic/logfire-node` (from `packages/logfire-node`) depends on `logfire` and adds automatic instrumentation via `@opentelemetry/auto-instrumentations-node`
- `@pydantic/logfire-cf-workers` depends on `logfire` and adds Cloudflare Workers-specific instrumentation
- `@pydantic/logfire-browser` depends on `logfire` and adds browser-specific instrumentation

### Key Concepts

**Trace API** (`logfire-api`):
**Trace API** (`logfire` package):

- Provides convenience wrappers around OpenTelemetry spans with log levels (trace, debug, info, notice, warn, error, fatal)
- Uses message template formatting with attribute extraction (see `formatter.ts`)
- Uses ULID for trace ID generation (see `ULIDGenerator.ts`)
- Supports attribute scrubbing for sensitive data (see `AttributeScrubber.ts`)

**Configuration** (`logfire` package):
**Configuration** (`@pydantic/logfire-node` package):

- `configure()` function in `logfireConfig.ts` handles SDK initialization
- Configuration can be provided programmatically or via environment variables:
Expand Down Expand Up @@ -79,7 +79,7 @@ npm run dev
npm run test

# Run tests for a specific package
cd packages/logfire && npm test
cd packages/logfire-node && npm test
```

### Linting and Type Checking
Expand Down Expand Up @@ -126,7 +126,7 @@ npm run release

```bash
# Navigate to the package
cd packages/logfire-api
cd packages/logfire-api # or packages/logfire-node

# Run vitest with a filter
npm test -- -t "test name pattern"
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ create an empty project:
mkdir test-logfire-js
cd test-logfire-js
npm init -y es6 # creates package.json with `type: module`
npm install logfire
npm install @pydantic/logfire-node
```

Then, create the following `hello.js` script in the directory:

```js
import * as logfire from "logfire";
import * as logfire from "@pydantic/logfire-node";

logfire.configure({
token: "test-e2e-write-token",
Expand All @@ -59,11 +59,11 @@ the live view of your Logfire project.

### Cloudflare Workers

First, install the `@pydantic/logfire-cf-workers @pydantic/logfire-api` NPM
First, install the `@pydantic/logfire-cf-workers logfire` NPM
packages:

```sh
npm install @pydantic/logfire-cf-workers @pydantic/logfire-api
npm install @pydantic/logfire-cf-workers logfire
```

Next, add `compatibility_flags = [ "nodejs_compat" ]` to your wrangler.toml or
Expand Down Expand Up @@ -94,7 +94,7 @@ function will extract your write token from the `env` object and provide the
necessary configuration for the instrumentation:

```ts
import * as logfire from "@pydantic/logfire-api";
import * as logfire from "logfire";
import { instrument } from "@pydantic/logfire-cf-workers";

const handler = {
Expand Down Expand Up @@ -159,11 +159,11 @@ This will point the instrumentation to Logfire.
> [clear the data cache for your project](https://vercel.com/docs/data-cache/manage-data-cache).

Optionally, you can use the Logfire API package for creating manual spans.
Install the `@pydantic/logfire-api` NPM package and call the respective methods
Install the `logfire` NPM package and call the respective methods
from your server-side code:

```tsx
import * as logfire from "@pydantic/logfire-api";
import * as logfire from "logfire";

export default async function Home() {
return logfire.span("A warning span", {}, {
Expand Down Expand Up @@ -206,11 +206,11 @@ app.listen(PORT, () => {
});
```

Next, install the `logfire` and `dotenv` NPM packages to keep your Logfire write
Next, install the `@pydantic/logfire-node` and `dotenv` NPM packages to keep your Logfire write
token in a `.env` file:

```sh
npm install logfire dotenv
npm install @pydantic/logfire-node dotenv
```

Add your token to the `.env` file:
Expand All @@ -220,11 +220,11 @@ LOGFIRE_TOKEN=your-write-token
```

Then, create an `instrumentation.ts` file to set up the instrumentation. The
`logfire` package includes a `configure` function that simplifies the setup:
`@pydantic/logfire-node` package includes a `configure` function that simplifies the setup:

```ts
// instrumentation.ts
import * as logfire from "logfire";
import * as logfire from "@pydantic/logfire-node";
import "dotenv/config";

logfire.configure();
Expand All @@ -247,7 +247,7 @@ The examples directory includes a `Hello world` example that configures Deno
OTel export to Logfire through environment variables.

Optionally, you can use the Logfire API package for creating manual spans.
Install the `@pydantic/logfire-api` NPM package and call the respective methods
Install the `logfire` NPM package and call the respective methods
from your code.

### Configuring the instrumentation
Expand All @@ -259,8 +259,8 @@ to configure the instrumentation.

## Trace API

The `@pydantic/logfire-api` exports several convenience wrappers around the
OpenTelemetry span creation API. The `logfire` package re-exports these.
The `logfire` package exports several convenience wrappers around the
OpenTelemetry span creation API. The `@pydantic/logfire-node` package re-exports these.

The following methods create spans with their respective log levels (ordered by
severity):
Expand Down
2 changes: 1 addition & 1 deletion examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"http-proxy-middleware": "^2.0.6"
},
"devDependencies": {
"@pydantic/logfire-api": "*",
"logfire": "*",
"@pydantic/logfire-browser": "*",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion examples/cf-producer-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"dependencies": {
"@microlabs/otel-cf-workers": "^1.0.0-rc.49",
"@pydantic/logfire-api": "*",
"logfire": "*",
"@pydantic/logfire-cf-workers": "*"
}
}
2 changes: 1 addition & 1 deletion examples/cf-producer-worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Learn more at https://developers.cloudflare.com/workers/
*/
import * as logfire from '@pydantic/logfire-api';
import * as logfire from 'logfire';
import { instrumentTail } from '@pydantic/logfire-cf-workers';

const handler = {
Expand Down
2 changes: 1 addition & 1 deletion examples/cf-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"wrangler": "^4.0.0"
},
"dependencies": {
"@pydantic/logfire-api": "*",
"logfire": "*",
"@pydantic/logfire-cf-workers": "*"
}
}
2 changes: 1 addition & 1 deletion examples/cf-worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Learn more at https://developers.cloudflare.com/workers/
*/
import * as logfire from '@pydantic/logfire-api';
import * as logfire from 'logfire';
import { instrument } from '@pydantic/logfire-cf-workers';

const handler = {
Expand Down
2 changes: 1 addition & 1 deletion examples/express/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Express, Request, Response } from "express";
import express from "express";
import * as logfire from "logfire";
import * as logfire from "@pydantic/logfire-node";

const PORT: number = parseInt(process.env.EXPRESS_PORT || "8080");
const app: Express = express();
Expand Down
2 changes: 1 addition & 1 deletion examples/express/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as logfire from 'logfire'
import * as logfire from '@pydantic/logfire-node'
import 'dotenv/config'

logfire.configure({
Expand Down
2 changes: 1 addition & 1 deletion examples/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@types/node": "^22.5.1",
"dotenv": "^16.4.7",
"express": "^4.21.2",
"logfire": "*",
"@pydantic/logfire-node": "*",
"tsx": "^4.19.0",
"typescript": "^5.5.4"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as logfire from "@pydantic/logfire-api";
import * as logfire from "logfire";

export async function GET() {
logfire.info("server endpoint");
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-client-side-instrumentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@opentelemetry/resources": "^1.19.0",
"@opentelemetry/sdk-trace-web": "^1.30.1",
"@opentelemetry/semantic-conventions": "^1.32.0",
"@pydantic/logfire-api": "*",
"logfire": "*",
"@pydantic/logfire-browser": "*",
"@vercel/otel": "^1.11.0",
"next": "15.3.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as logfire from '@pydantic/logfire-api'
import * as logfire from 'logfire'

/** Add your relevant code here for the issue to reproduce */
export default async function Home() {
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"@vercel/otel": "^1.10.3",
"@pydantic/logfire-api": "*",
"logfire": "*",
"next": "15.2.1",
"react": "^19.0.0",
"react-dom": "^19.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'dotenv/config'
import * as logfire from 'logfire'
import * as logfire from '@pydantic/logfire-node'

logfire.configure({
serviceName: 'example-node-script',
Expand Down
2 changes: 1 addition & 1 deletion examples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"description": "",
"dependencies": {
"dotenv": "^16.4.7",
"logfire": "*"
"@pydantic/logfire-node": "*"
},
"devDependencies": {
"@opentelemetry/semantic-conventions": "^1.30.0",
Expand Down
Loading
Loading