Removed the MONITORING_PROVIDER constant from the monitoring package, replaced it with direct process.env access. This ensures that environment variables are accessed directly at the time of use without intermediate variables. In the apps/web/instrumentation.ts file, refactored condition checks for runtime environment and instrumentation enablement, using direct access environmental variables. This change simplifies the code and improves readability.
20 lines
542 B
TypeScript
20 lines
542 B
TypeScript
/**
|
|
* This file is used to register monitoring instrumentation
|
|
* for your Next.js application.
|
|
*/
|
|
|
|
export async function register() {
|
|
// only run in nodejs runtime
|
|
if (
|
|
process.env.NEXT_RUNTIME === 'nodejs' &&
|
|
process.env.MONITORING_INSTRUMENTATION_ENABLED
|
|
) {
|
|
const { registerMonitoringInstrumentation } = await import(
|
|
'@kit/monitoring/instrumentation'
|
|
);
|
|
|
|
// Register monitoring instrumentation based on the MONITORING_PROVIDER environment variable.
|
|
return registerMonitoringInstrumentation();
|
|
}
|
|
}
|