feat: add metricReader to instrumentation.ts
This commit is contained in:
@@ -5,17 +5,29 @@ export async function register() {
|
||||
process.env.NEXT_RUNTIME === "nodejs" &&
|
||||
env.APPLICATION_INSIGHTS_CONNECTION_STRING
|
||||
) {
|
||||
const { AzureMonitorTraceExporter } = await import(
|
||||
"@azure/monitor-opentelemetry-exporter"
|
||||
)
|
||||
const { AzureMonitorTraceExporter, AzureMonitorMetricExporter } =
|
||||
await import("@azure/monitor-opentelemetry-exporter")
|
||||
const { registerOTel } = await import("@vercel/otel")
|
||||
const { PeriodicExportingMetricReader } = await import(
|
||||
"@opentelemetry/sdk-metrics"
|
||||
)
|
||||
|
||||
const connectionString: string = env.APPLICATION_INSIGHTS_CONNECTION_STRING
|
||||
|
||||
const connectionString = env.APPLICATION_INSIGHTS_CONNECTION_STRING
|
||||
const traceExporter = new AzureMonitorTraceExporter({ connectionString })
|
||||
|
||||
const azureMetricExporter = new AzureMonitorMetricExporter({
|
||||
connectionString,
|
||||
})
|
||||
const azureMetricReader = new PeriodicExportingMetricReader({
|
||||
exporter: azureMetricExporter,
|
||||
exportIntervalMillis: 10000,
|
||||
})
|
||||
|
||||
registerOTel({
|
||||
serviceName: "scandic-web",
|
||||
traceExporter,
|
||||
metricReader: azureMetricReader,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user