The monitoring package has been significantly refactored to improve the granularity of error capture. Code from the 'capture-exception.ts' files in different locations have been deleted and replaced by a more unified approach in the 'use-baselime.ts' and 'use-sentry.ts' hooks. The README documentation has also been updated to reflect these changes and provide additional information about error monitoring setup and usage.
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { getMonitoringProvider } from './get-monitoring-provider';
|
|
import { InstrumentationProvider } from './monitoring-providers.enum';
|
|
|
|
const PROVIDER = getMonitoringProvider();
|
|
|
|
/**
|
|
* @name registerMonitoringInstrumentation
|
|
* @description Register monitoring instrumentation based on the MONITORING_PROVIDER environment variable.
|
|
*
|
|
* Please set the MONITORING_PROVIDER environment variable to register the monitoring instrumentation provider.
|
|
*/
|
|
export async function registerMonitoringInstrumentation() {
|
|
if (!PROVIDER) {
|
|
console.info(`No instrumentation provider specified. Skipping...`);
|
|
|
|
return;
|
|
}
|
|
|
|
switch (PROVIDER) {
|
|
case InstrumentationProvider.Baselime: {
|
|
const { registerInstrumentation } = await import(
|
|
'@kit/baselime/instrumentation'
|
|
);
|
|
|
|
return registerInstrumentation();
|
|
}
|
|
|
|
case InstrumentationProvider.Sentry: {
|
|
const { registerInstrumentation } = await import(
|
|
'@kit/sentry/instrumentation'
|
|
);
|
|
|
|
return registerInstrumentation();
|
|
}
|
|
|
|
default:
|
|
throw new Error(
|
|
`Unknown instrumentation provider: ${process.env.MONITORING_PROVIDER}`,
|
|
);
|
|
}
|
|
}
|