committed by
GitHub
parent
aba9076805
commit
c9f0ec5d89
@@ -1,35 +1,3 @@
|
||||
# Sentry Monitoring / @kit/sentry
|
||||
|
||||
Please set the following environment variable:
|
||||
|
||||
```bash
|
||||
NEXT_PUBLIC_MONITORING_PROVIDER=sentry
|
||||
NEXT_PUBLIC_SENTRY_DSN=your_dsn
|
||||
```
|
||||
|
||||
Create the following file at the root of your project:
|
||||
|
||||
```tsx title="sentry.client.config.ts"
|
||||
export * from '@kit/sentry/config/client';
|
||||
```
|
||||
|
||||
Create the following file at the root of your project:
|
||||
|
||||
```tsx title="sentry.server.config.ts"
|
||||
export * from '@kit/sentry/config/server';
|
||||
```
|
||||
|
||||
Create the following file at the root of your project:
|
||||
|
||||
```tsx title="sentry.edge.config.ts"
|
||||
export * from '@kit/sentry/config/edge';
|
||||
```
|
||||
|
||||
Finally, update the Next.js configuration in your `next.config.js` file:
|
||||
|
||||
```tsx title="next.config.mjs"
|
||||
import { withSentryConfig } from "@sentry/nextjs";
|
||||
|
||||
// wrap your Next.js configuration with the Sentry configuration
|
||||
withSentryConfig(nextConfig);
|
||||
```
|
||||
Please refer to the [documentation](https://makerkit.dev/docs/next-supabase-turbo/sentry).
|
||||
@@ -12,17 +12,11 @@
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./provider": "./src/components/provider.tsx",
|
||||
"./instrumentation": "./src/instrumentation.ts",
|
||||
"./config/client": "./src/sentry.client.config.ts",
|
||||
"./config/server": "./src/sentry.client.server.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@opentelemetry/exporter-jaeger": "1.24.1",
|
||||
"@opentelemetry/resources": "1.24.1",
|
||||
"@opentelemetry/sdk-node": "0.51.1",
|
||||
"@opentelemetry/semantic-conventions": "^1.24.1",
|
||||
"@sentry/nextjs": "^8.7.0",
|
||||
"@sentry/opentelemetry-node": "^7.114.0"
|
||||
"@sentry/nextjs": "^8.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/eslint-config": "workspace:*",
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* @name registerInstrumentation
|
||||
* @description This file is used to register Sentry instrumentation for your Next.js application.
|
||||
*
|
||||
* Please set the MONITORING_PROVIDER environment variable to 'sentry' to register Sentry instrumentation.
|
||||
*/
|
||||
export async function registerInstrumentation() {
|
||||
const { initializeSentryServerClient } = await import(
|
||||
'./sentry.server.config'
|
||||
);
|
||||
|
||||
// initialize the Sentry client in the server
|
||||
void initializeSentryServerClient();
|
||||
|
||||
if (process.env.ENABLE_MONITORING_INSTRUMENTATION !== 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure the instrumentation is only run in a Node.js environment
|
||||
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
||||
const serviceName = process.env.INSTRUMENTATION_SERVICE_NAME;
|
||||
|
||||
if (!serviceName) {
|
||||
throw new Error(
|
||||
`You have set the Sentry instrumentation provider, but have not set the INSTRUMENTATION_SERVICE_NAME environment variable. Please set the INSTRUMENTATION_SERVICE_NAME environment variable.`,
|
||||
);
|
||||
}
|
||||
|
||||
const { Resource } = await import('@opentelemetry/resources');
|
||||
const { NodeSDK } = await import('@opentelemetry/sdk-node');
|
||||
|
||||
const { SEMRESATTRS_SERVICE_NAME } = await import(
|
||||
'@opentelemetry/semantic-conventions'
|
||||
);
|
||||
|
||||
const { SentrySpanProcessor, SentryPropagator } = await import(
|
||||
'@sentry/opentelemetry-node'
|
||||
);
|
||||
|
||||
const sdk = new NodeSDK({
|
||||
resource: new Resource({
|
||||
[SEMRESATTRS_SERVICE_NAME]: serviceName,
|
||||
}),
|
||||
spanProcessors: [new SentrySpanProcessor()],
|
||||
textMapPropagator: new SentryPropagator(),
|
||||
});
|
||||
|
||||
sdk.start();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user