Merged in feat/sentry (pull request #1089)
This commit is contained in:
committed by
Joakim Jäderberg
parent
e0c5b59860
commit
3982b1ba56
@@ -1,6 +1,15 @@
|
||||
import * as Sentry from "@sentry/nextjs"
|
||||
|
||||
import { env } from "./env/server"
|
||||
|
||||
export async function register() {
|
||||
await configureSentry()
|
||||
await configureApplicationInsights()
|
||||
}
|
||||
|
||||
export const onRequestError = Sentry.captureRequestError
|
||||
|
||||
async function configureApplicationInsights() {
|
||||
if (
|
||||
process.env.NEXT_RUNTIME === "nodejs" &&
|
||||
env.APPLICATION_INSIGHTS_CONNECTION_STRING
|
||||
@@ -11,11 +20,8 @@ export async function register() {
|
||||
const { PeriodicExportingMetricReader } = await import(
|
||||
"@opentelemetry/sdk-metrics"
|
||||
)
|
||||
|
||||
const connectionString: string = env.APPLICATION_INSIGHTS_CONNECTION_STRING
|
||||
|
||||
const traceExporter = new AzureMonitorTraceExporter({ connectionString })
|
||||
|
||||
const azureMetricExporter = new AzureMonitorMetricExporter({
|
||||
connectionString,
|
||||
})
|
||||
@@ -23,7 +29,6 @@ export async function register() {
|
||||
exporter: azureMetricExporter,
|
||||
exportIntervalMillis: 10000,
|
||||
})
|
||||
|
||||
registerOTel({
|
||||
serviceName: "scandic-web",
|
||||
traceExporter,
|
||||
@@ -31,3 +36,14 @@ export async function register() {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function configureSentry() {
|
||||
switch (process.env.NEXT_RUNTIME) {
|
||||
case "edge": {
|
||||
await import("./sentry.edge.config")
|
||||
}
|
||||
case "nodejs": {
|
||||
await import("./sentry.server.config")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user