← Docs
RECIPE

OpenTelemetry Setup

Instrument Meridian with OTLP exporters for traces, metrics, and logs. Ship telemetry to your collector in under ten minutes.

Prerequisites

  • Node.js 18+ runtime
  • OTLP-compatible collector (Jaeger, Grafana Agent, or otelcol)
  • Meridian SDK v2.4 or later

Step 1 — Install packages

npm install @opentelemetry/api @opentelemetry/sdk-node @opentelemetry/exporter-trace-otlp-http

Step 2 — Bootstrap the SDK

Create instrumentation.ts at your project root. This file initializes the NodeSDK before any application code loads.

import { NodeSDK } from "@opentelemetry/sdk-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";

const sdk = new NodeSDK({
  traceExporter: new OTLPTraceExporter({
    url: "http://localhost:4318/v1/traces",
  }),
});

sdk.start();

Step 3 — Wire into Meridian

Import the instrumentation file at the top of your entrypoint. Meridian auto-detects the active TracerProvider and attaches span context to every request.

// index.ts
import "./instrumentation";
import { Meridian } from "@meridian/sdk";

const app = new Meridian();
app.listen(3000);

Verification

Send a request to your endpoint and check your collector UI. You should see a trace named HTTP > /your-route with Meridian-injected attributes including meridian.session_id and meridian.license_tier.