Last active
December 11, 2023 21:23
-
-
Save itzsaga/f76684652a02d5625ed4e4b7ff49e99a to your computer and use it in GitHub Desktop.
Datadog APM w/ OTEL in Next.js in standalone mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http' | |
import { Resource } from '@opentelemetry/resources' | |
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' | |
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node' | |
const tracer = require('dd-trace').init() | |
const { TracerProvider } = tracer | |
const provider = new TracerProvider({ | |
resource: new Resource({ | |
[SemanticResourceAttributes.SERVICE_NAME]: 'app', | |
}), | |
spanProcessor: new SimpleSpanProcessor(new OTLPTraceExporter()), | |
}) | |
provider.register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function register() { | |
if (process.env.NEXT_RUNTIME === 'nodejs') { | |
await import('./instrumentation.node') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment