Skip to main content
All recipes

OpenTelemetry.

CodeGenericOTLP

Use the SDK's `beforeSend` hook to mirror every captured event into your OpenTelemetry pipeline. Lets you correlate upstream health signals against the rest of your trace and metric data without leaving your APM.

Mirror events to your OTel exporter.

instrumentation.ts
import { metrics } from "@opentelemetry/api";
import { initCheckUpstream } from "@checkupstream/sdk/integrations/next";

const meter = metrics.getMeter("checkupstream");
const latency = meter.createHistogram("upstream.latency_ms", { unit: "ms" });
const errors = meter.createCounter("upstream.errors");

export function register() {
  initCheckUpstream({
    sdkKey: process.env.CHECKUPSTREAM_SDK_KEY!,
    beforeSend: (events) => {
      for (const e of events) {
        latency.record(e.latency_ms, { service: e.service, method: e.method });
        if (e.error_class) {
          errors.add(1, { service: e.service, error_class: e.error_class });
        }
      }
      // Return the events so CheckUpstream still ingests them.
      return events;
    },
  });
}

Ship reliable upstream.

Drop the SDK in, point it at your project key, and start seeing live upstream telemetry inside the dashboard.