Refactor monitoring instrumentation setup
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.
This commit is contained in:
@@ -53,4 +53,8 @@ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
|
||||
NEXT_PUBLIC_ENABLE_ACCOUNT_DELETION=true
|
||||
NEXT_PUBLIC_ENABLE_PERSONAL_ACCOUNT_BILLING=true
|
||||
NEXT_PUBLIC_ENABLE_ORGANIZATION_DELETION=true
|
||||
NEXT_PUBLIC_ENABLE_ORGANIZATION_BILLING=true
|
||||
NEXT_PUBLIC_ENABLE_ORGANIZATION_BILLING=true
|
||||
|
||||
# MONITORING
|
||||
MONITORING_PROVIDER=
|
||||
MONITORING_INSTRUMENTATION_ENABLED=false
|
||||
@@ -3,14 +3,12 @@
|
||||
* for your Next.js application.
|
||||
*/
|
||||
|
||||
const RUNTIME = process.env.NEXT_RUNTIME;
|
||||
|
||||
const ENABLE_INSTRUMENTATION =
|
||||
process.env.MONITORING_INSTRUMENTATION_ENABLED === 'true';
|
||||
|
||||
export async function register() {
|
||||
// only run in nodejs runtime
|
||||
if (RUNTIME === 'nodejs' && ENABLE_INSTRUMENTATION) {
|
||||
if (
|
||||
process.env.NEXT_RUNTIME === 'nodejs' &&
|
||||
process.env.MONITORING_INSTRUMENTATION_ENABLED
|
||||
) {
|
||||
const { registerMonitoringInstrumentation } = await import(
|
||||
'@kit/monitoring/instrumentation'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user