Refactor monitoring package and improve error handling

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.
This commit is contained in:
giancarlo
2024-04-22 15:24:01 +08:00
parent 3ce6c62425
commit b6d303f90e
37 changed files with 2362 additions and 2106 deletions

View File

@@ -1,5 +1,8 @@
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.
@@ -7,13 +10,13 @@ import { InstrumentationProvider } from './monitoring-providers.enum';
* Please set the MONITORING_PROVIDER environment variable to register the monitoring instrumentation provider.
*/
export async function registerMonitoringInstrumentation() {
if (!process.env.MONITORING_PROVIDER) {
if (!PROVIDER) {
console.info(`No instrumentation provider specified. Skipping...`);
return;
}
switch (process.env.MONITORING_PROVIDER as InstrumentationProvider) {
switch (PROVIDER) {
case InstrumentationProvider.Baselime: {
const { registerInstrumentation } = await import(
'@kit/baselime/instrumentation'