Using `@effect/opentelemetry` with Next.js for OTel Node SDK Initialization

Question about @effect/opentelemetry and Next.js:

Vercel has added an instrumentation hook to Next.js: https://vercel.com/docs/observability/otel-overview/quickstart

I would like to use it to initialize the OTel Node SDK, which I do now in a file otel.node.ts:

import * as NodeSdk from '@effect/opentelemetry/NodeSdk';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';

export const OtelNodeLive = NodeSdk.layer(() => ({
  resource: {
    serviceName: 'my-app',
  },
  spanProcessor: new SimpleSpanProcessor(new OTLPTraceExporter()),
}));


Afaict the only thing I would need to do is import this, get the NodeTracerProvider from inside the Layer, and call .register() on it in the instrumentation callback. However, I can't quite figure out how to get the NodeTracerProvider. Did someone manage to successfully set up @effect/opentelemetry for Next.js?

I found the Tracer.TracerProvider tag, but that doesn't yield the NodeTracerProvider. and besides NodeSdk.layer also doesn't provide the NodeTracerProvider.
Was this page helpful?