Skip to main content
@squasher-ai/pino ships two things in one package:
  1. squasherTransport() — a Pino transport that forwards log events to Squasher. Drop-in for existing Pino setups.
  2. span() / log / recordMetric() — the same OpenTelemetry-compatible tracing primitives as @squasher-ai/edge, but for Node services.
Same API across edge and Node. Pure OTLP wire format under the hood, so no vendor lock-in.

Install

Node ≥ 18 required (native fetch + AsyncLocalStorage).

60-second example

src/server.ts
Spans auto-nest via AsyncLocalStorage. Logs and metrics emitted inside a span auto-correlate.

The Pino transport

Forwards Pino log events to Squasher’s ingest endpoint with batching, retries, and level mapping.
src/logger.ts
When you pass an err object, Squasher extracts the error message, type, and stack trace automatically.

Transport options

The transport automatically splits multi-event request bodies at 1 MB. batchSize and flushIntervalMs still determine when buffered events are flushed.

Tracing primitives

Same API as @squasher-ai/edge. Quick version below — see the edge SDK page for the full reference.

initSquasher(config) — one-time startup

Call once at process startup. Sets up the global tracing client and auto-registers a beforeExit handler that flushes pending events.

span(name, fn) — one-line spans

Nested spans auto-parent. Errors are auto-captured with status: "error" and re-thrown unchanged.

log.{debug, info, warn, error}(message, attrs?)

These are the SDK’s structured-log helpers, separate from your Pino logger. Use them when you want the log to attach to the active span. Plain Pino records also correlate when they include trace_id and span_id, traceId and spanId, or trace.id and span.id.

recordMetric(name, value, opts?)

Cross-process traces

Propagate via W3C traceparent to outbound HTTP:
The receiving service (Node or Cloudflare Worker) reconstructs the parent and passes parent: { traceId, spanId } to its own span() call.

Why both the transport AND tracing primitives?

  • Pino transport is for logs. Drop-in for existing Pino setups, zero code changes.
  • span() / log.* / recordMetric() are for traces, metrics, and structured logs that need to correlate to spans.
Most apps use both. Pino logs that don’t need trace correlation flow through the transport. Spans + metrics + structured log calls that should attach to a trace go through the tracing helpers.

Switch destinations

The SDK sends the Squasher ingest event format to the configured Squasher endpoint. Use the OpenTelemetry integration when you need a standard OTLP exporter or collector destination.

API reference

Agent handoff