feat: add metricReader to instrumentation.ts
This commit is contained in:
@@ -5,17 +5,29 @@ export async function register() {
|
|||||||
process.env.NEXT_RUNTIME === "nodejs" &&
|
process.env.NEXT_RUNTIME === "nodejs" &&
|
||||||
env.APPLICATION_INSIGHTS_CONNECTION_STRING
|
env.APPLICATION_INSIGHTS_CONNECTION_STRING
|
||||||
) {
|
) {
|
||||||
const { AzureMonitorTraceExporter } = await import(
|
const { AzureMonitorTraceExporter, AzureMonitorMetricExporter } =
|
||||||
"@azure/monitor-opentelemetry-exporter"
|
await import("@azure/monitor-opentelemetry-exporter")
|
||||||
)
|
|
||||||
const { registerOTel } = await import("@vercel/otel")
|
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 traceExporter = new AzureMonitorTraceExporter({ connectionString })
|
||||||
|
|
||||||
|
const azureMetricExporter = new AzureMonitorMetricExporter({
|
||||||
|
connectionString,
|
||||||
|
})
|
||||||
|
const azureMetricReader = new PeriodicExportingMetricReader({
|
||||||
|
exporter: azureMetricExporter,
|
||||||
|
exportIntervalMillis: 10000,
|
||||||
|
})
|
||||||
|
|
||||||
registerOTel({
|
registerOTel({
|
||||||
serviceName: "scandic-web",
|
serviceName: "scandic-web",
|
||||||
traceExporter,
|
traceExporter,
|
||||||
|
metricReader: azureMetricReader,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -14,6 +14,8 @@
|
|||||||
"@hookform/error-message": "^2.0.1",
|
"@hookform/error-message": "^2.0.1",
|
||||||
"@hookform/resolvers": "^3.3.4",
|
"@hookform/resolvers": "^3.3.4",
|
||||||
"@netlify/plugin-nextjs": "^5.1.1",
|
"@netlify/plugin-nextjs": "^5.1.1",
|
||||||
|
"@opentelemetry/api": "^1.9.0",
|
||||||
|
"@opentelemetry/sdk-metrics": "^1.25.1",
|
||||||
"@radix-ui/react-slot": "^1.0.2",
|
"@radix-ui/react-slot": "^1.0.2",
|
||||||
"@react-aria/ssr": "^3.9.5",
|
"@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",
|
"@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/error-message": "^2.0.1",
|
||||||
"@hookform/resolvers": "^3.3.4",
|
"@hookform/resolvers": "^3.3.4",
|
||||||
"@netlify/plugin-nextjs": "^5.1.1",
|
"@netlify/plugin-nextjs": "^5.1.1",
|
||||||
|
"@opentelemetry/api": "^1.9.0",
|
||||||
|
"@opentelemetry/sdk-metrics": "^1.25.1",
|
||||||
"@radix-ui/react-slot": "^1.0.2",
|
"@radix-ui/react-slot": "^1.0.2",
|
||||||
"@react-aria/ssr": "^3.9.5",
|
"@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",
|
"@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