Pino
Ship Pino log records to AxonPush as OpenTelemetry-shaped app.log events. Pino is the fastest Node.js logger and the modern standard for backend services.
[!TIP] Non-blocking by default (v0.0.2+)
The returned stream pushes each record onto a bounded in-memory queue and drains it from a single background task, so
log.info(...)stays O(microseconds) on the caller’s path. Callstream.flush(timeoutMs?)at known checkpoints to guarantee delivery. Passmode: "sync"for blocking publishes.
Installation
Section titled “Installation”npm install @axonpush/sdk pinoimport pino from "pino";import { AxonPush } from "@axonpush/sdk";import { createAxonPushPinoStream } from "@axonpush/sdk/integrations/pino";
const client = new AxonPush({ apiKey: process.env.AXONPUSH_API_KEY!, tenantId: process.env.AXONPUSH_TENANT_ID!,});
const stream = createAxonPushPinoStream({ client, channelId: 1, serviceName: "my-api", environment: "production",});
const log = pino({ level: "info" }, stream);Log normally — Pino structured fields become OTel attributes:
log.info({ userId: 42, method: "oauth" }, "user signed in");log.warn({ endpoint: "/api/search", remaining: 3 }, "rate limit approaching");log.error({ endpoint: "/api/search", elapsedMs: 5000 }, "downstream timeout");AWS Lambda / serverless
Section titled “AWS Lambda / serverless”Wrap your handler with flushAfterInvocation so the stream drains
before the container freezes:
import { flushAfterInvocation } from "@axonpush/sdk/integrations/pino";
export const handler = flushAfterInvocation(stream, async (event, _ctx) => { log.info({ event }, "processing event"); return { statusCode: 200 };});Flushing and closing
Section titled “Flushing and closing”await stream.flush(1000); // block until queue drained, up to 1 secondawait stream.close(); // drain pending records and stop the workerstream.close() is also called automatically by the module-level
beforeExit / SIGTERM / SIGINT hook at process shutdown.
Constructor options
Section titled “Constructor options”| Option | Type | Default | Description |
|---|---|---|---|
client | AxonPush | required | The pre-built SDK client. |
channelId | number | required | Target channel for log events. |
serviceName | string | — | OTel service.name resource attribute. |
serviceVersion | string | — | OTel service.version. |
environment | string | — | OTel deployment.environment. |
agentId | string | — | Optional agent correlation ID. |
mode | "background" | "sync" | "background" | Publishing mode. |
queueSize | number | 1000 | Max records buffered before drop. |
shutdownTimeoutMs | number | 2000 | Time to wait for drain on close(). |
concurrency | number | 1 | Parallel in-flight publishes. |
Events
Section titled “Events”| Field | Value |
|---|---|
identifier | "pino" |
eventType | "app.log" |
payload.body | The Pino msg field |
payload.severityNumber / payload.severityText | OTel severity mapped from Pino’s numeric level (10→TRACE, 20→DEBUG, 30→INFO, 40→WARN, 50→ERROR, 60→FATAL) |
payload.attributes | All non-standard fields from the Pino record plus host.name, process.pid |
payload.resource | service.name, service.version, deployment.environment (if configured) |