Refactor monitoring services into separate packages
Separated and isolated the responsibilities of monitoring tools. Reorganized the code by introducing a core package that contains common code related to monitoring and moved all the service operations like error capturing and identification of users into their respective packages. This ensures each tool is independent and easy to maintain.
This commit is contained in:
41
packages/monitoring/api/src/instrumentation.ts
Normal file
41
packages/monitoring/api/src/instrumentation.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
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}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user