import { NodeSDK } from '@opentelemetry/sdk-node'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'
const sdk = new NodeSDK({
serviceName: 'nextjs-otel-app',
traceExporter: new OTLPTraceExporter({
url:
process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ||
'http://localhost:4318/v1/traces',
}),
instrumentations: [new HttpInstrumentation(), new ExpressInstrumentation()],
})
sdk.start()