diff --git a/App/Index.ts b/App/Index.ts index 8148b6b2f8e..dffa8a38ce4 100755 --- a/App/Index.ts +++ b/App/Index.ts @@ -22,11 +22,12 @@ const APP_NAME: string = "app"; const init: PromiseVoidFunction = async (): Promise => { try { + // Initialize telemetry Telemetry.init({ serviceName: APP_NAME, }); - + const statusCheck: PromiseVoidFunction = async (): Promise => { // Check the status of infrastructure components return await InfrastructureStatus.checkStatus({ diff --git a/CommonServer/Utils/Telemetry.ts b/CommonServer/Utils/Telemetry.ts index 6891dd2efae..2296461a538 100644 --- a/CommonServer/Utils/Telemetry.ts +++ b/CommonServer/Utils/Telemetry.ts @@ -102,6 +102,7 @@ export default class Telemetry { } public static init(data: { serviceName: string }): opentelemetry.NodeSDK { + if (!this.sdk) { const headers: Dictionary = this.getHeaders(); @@ -149,7 +150,7 @@ export default class Telemetry { logs.setGlobalLoggerProvider(loggerProvider); - this.logger = logs.getLogger("default"); + const nodeSdkConfiguration: Partial = { @@ -189,10 +190,10 @@ export default class Telemetry { public static getLogger(): Logger { if (!this.logger) { - throw new Error("Logger not initialized"); + this.logger = logs.getLogger("default"); } - return this.logger!; + return this.logger; } public static getMeterProvider(): MeterProvider { diff --git a/docker-compose.base.yml b/docker-compose.base.yml index 03773f86119..4048eef7833 100644 --- a/docker-compose.base.yml +++ b/docker-compose.base.yml @@ -47,6 +47,9 @@ x-common-variables: &common-variables ADMIN_DASHBOARD_PORT: ${ADMIN_DASHBOARD_PORT} ISOLATED_VM_PORT: ${ISOLATED_VM_PORT} + OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT: ${OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT} + OPENTELEMETRY_EXPORTER_OTLP_HEADERS: ${OPENTELEMETRY_EXPORTER_OTLP_HEADERS} + x-common-ui-variables: &common-ui-variables <<: *common-variables IS_SERVER: "false" @@ -172,8 +175,6 @@ services: environment: <<: *common-ui-variables PORT: ${ACCOUNTS_PORT} - OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT: ${OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT} - OPENTELEMETRY_EXPORTER_OTLP_HEADERS: ${OPENTELEMETRY_EXPORTER_OTLP_HEADERS} logging: driver: "local" @@ -204,8 +205,7 @@ services: environment: <<: *common-ui-variables PORT: ${ADMIN_DASHBOARD_PORT} - OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT: ${OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT} - OPENTELEMETRY_EXPORTER_OTLP_HEADERS: ${OPENTELEMETRY_EXPORTER_OTLP_HEADERS} + logging: driver: "local" options: @@ -218,8 +218,7 @@ services: environment: <<: *common-ui-variables PORT: ${DASHBOARD_PORT} - OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT: ${OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT} - OPENTELEMETRY_EXPORTER_OTLP_HEADERS: ${OPENTELEMETRY_EXPORTER_OTLP_HEADERS} + logging: driver: "local" options: @@ -234,8 +233,6 @@ services: environment: <<: *common-ui-variables PORT: ${STATUS_PAGE_PORT} - OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT: ${OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT} - OPENTELEMETRY_EXPORTER_OTLP_HEADERS: ${OPENTELEMETRY_EXPORTER_OTLP_HEADERS} logging: driver: "local" options: @@ -270,8 +267,6 @@ services: INTERNAL_SMTP_EMAIL: ${INTERNAL_SMTP_EMAIL} INTERNAL_SMTP_FROM_NAME: ${INTERNAL_SMTP_FROM_NAME} INTERNAL_SMTP_PASSWORD: ${INTERNAL_SMTP_PASSWORD} - OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT: ${OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT} - OPENTELEMETRY_EXPORTER_OTLP_HEADERS: ${OPENTELEMETRY_EXPORTER_OTLP_HEADERS} logging: driver: "local" options: @@ -292,8 +287,6 @@ services: PROBE_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS: ${GLOBAL_PROBE_1_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS} ONEUPTIME_URL: ${GLOBAL_PROBE_1_ONEUPTIME_URL} PROBE_MONITOR_FETCH_LIMIT: ${GLOBAL_PROBE_1_MONITOR_FETCH_LIMIT} - OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT: ${OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT} - OPENTELEMETRY_EXPORTER_OTLP_HEADERS: ${OPENTELEMETRY_EXPORTER_OTLP_HEADERS} logging: driver: "local" options: @@ -314,8 +307,6 @@ services: PROBE_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS: ${GLOBAL_PROBE_2_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS} PROBE_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS: ${GLOBAL_PROBE_2_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS} PROBE_MONITOR_FETCH_LIMIT: ${GLOBAL_PROBE_2_MONITOR_FETCH_LIMIT} - OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT: ${OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT} - OPENTELEMETRY_EXPORTER_OTLP_HEADERS: ${OPENTELEMETRY_EXPORTER_OTLP_HEADERS} logging: driver: "local" options: