Files
myeasycms-v2/packages/monitoring/baselime/src/index.ts
giancarlo 24a68b2b1f Add Sentry and Baselime packages in the monitoring section
This commit introduces Sentry and Baselime packages into the monitoring section, complete with associated dependencies and scripts. These changes also reflect necessary updates to the 'pnpm-lock.yaml' file to account for these new dependencies.
2024-04-04 01:09:19 +08:00

34 lines
1020 B
TypeScript

import {
BaselimeSDK,
BetterHttpInstrumentation,
VercelPlugin,
} from '@baselime/node-opentelemetry';
const INSTRUMENTATION_SERVICE_NAME = process.env.INSTRUMENTATION_SERVICE_NAME;
if (!INSTRUMENTATION_SERVICE_NAME) {
throw new Error(`
You have set the Baselime instrumentation provider, but have not set the INSTRUMENTATION_SERVICE_NAME environment variable. Please set the INSTRUMENTATION_SERVICE_NAME environment variable.
`);
}
/**
* @name registerBaselimeInstrumentation
* @description This file is used to register Baselime instrumentation for your Next.js application.
*
* Please set the MONITORING_INSTRUMENTATION_PROVIDER environment variable to 'baselime' to register Baselime instrumentation.
*/
export function registerBaselimeInstrumentation() {
const sdk = new BaselimeSDK({
serverless: true,
service: INSTRUMENTATION_SERVICE_NAME,
instrumentations: [
new BetterHttpInstrumentation({
plugins: [new VercelPlugin()],
}),
],
});
sdk.start();
}