Skip to content
GitHub

Observability Package

Structured logging, error tracking, and Web Vitals monitoring with Axiom.

# Get token from axiom.co
# Add to apps/api/.env.local
AXIOM_TOKEN=xaat-...
AXIOM_DATASET=orion-logs

API routes:

import { withAxiom, logger } from "@workspace/observability";

export const GET = withAxiom(async (req) => {
  logger.info("Fetching data", { userId, count: 10 });
  // Auto-logs request/response + duration
  return NextResponse.json({ data });
});

Client-side performance:

import { WebVitals } from "@workspace/observability/client";

// In app/layout.tsx
<WebVitals /> // Tracks LCP, FID, CLS, TTFB
// ✅ Good - structured
logger.info("Task created", { userId, taskId, status });

// ❌ Bad - unstructured
logger.info(`User ${userId} created task ${taskId}`);

Levels: debug, info, warn, error

View logs at axiom.co:

['orion-logs']
| where level == "error"
| where _time > ago(1h)

Set up alerts for high error rates or slow requests.

Axiom docs · Web Vitals