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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -14,6 +14,8 @@
|
||||
"@hookform/error-message": "^2.0.1",
|
||||
"@hookform/resolvers": "^3.3.4",
|
||||
"@netlify/plugin-nextjs": "^5.1.1",
|
||||
"@opentelemetry/api": "^1.9.0",
|
||||
"@opentelemetry/sdk-metrics": "^1.25.1",
|
||||
"@radix-ui/react-slot": "^1.0.2",
|
||||
"@react-aria/ssr": "^3.9.5",
|
||||
"@scandic-hotels/design-system": "git+https://x-token-auth:$DESIGN_SYSTEM_ACCESS_TOKEN@bitbucket.org/scandic-swap/design-system.git#v0.1.0-rc.8",
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
"@hookform/error-message": "^2.0.1",
|
||||
"@hookform/resolvers": "^3.3.4",
|
||||
"@netlify/plugin-nextjs": "^5.1.1",
|
||||
"@opentelemetry/api": "^1.9.0",
|
||||
"@opentelemetry/sdk-metrics": "^1.25.1",
|
||||
"@radix-ui/react-slot": "^1.0.2",
|
||||
"@react-aria/ssr": "^3.9.5",
|
||||
"@scandic-hotels/design-system": "git+https://x-token-auth:$DESIGN_SYSTEM_ACCESS_TOKEN@bitbucket.org/scandic-swap/design-system.git#v0.1.0-rc.8",
|
||||
|
||||
Reference in New Issue
Block a user