diff --git a/CommonServer/Utils/Telemetry.ts b/CommonServer/Utils/Telemetry.ts index 0c94f9265a..d85567ac00 100644 --- a/CommonServer/Utils/Telemetry.ts +++ b/CommonServer/Utils/Telemetry.ts @@ -94,12 +94,14 @@ export default class Telemetry { if (!this.sdk) { const headers: Dictionary = this.getHeaders(); + const hasHeaders: boolean = Object.keys(headers).length > 0; + let traceExporter: SpanExporter | undefined = undefined; let metricReader: PeriodicExportingMetricReader | undefined = undefined; - if (this.getOltpTracesEndpoint()) { + if (this.getOltpTracesEndpoint() && hasHeaders) { traceExporter = new OTLPTraceExporter({ url: this.getOltpTracesEndpoint()!.toString(), headers: headers, @@ -107,7 +109,7 @@ export default class Telemetry { }); } - if (this.getOltpMetricsEndpoint()) { + if (this.getOltpMetricsEndpoint() && hasHeaders) { metricReader = new PeriodicExportingMetricReader({ exporter: new OTLPMetricExporter({ url: this.getOltpMetricsEndpoint()!.toString(), @@ -119,7 +121,7 @@ export default class Telemetry { const loggerProvider: LoggerProvider = new LoggerProvider(); - if (this.getOltpLogsEndpoint()) { + if (this.getOltpLogsEndpoint() && hasHeaders) { const logExporter: OTLPLogExporter = new OTLPLogExporter({ url: this.getOltpLogsEndpoint()!.toString(), headers: headers, diff --git a/CommonUI/src/Utils/Telemetry.ts b/CommonUI/src/Utils/Telemetry.ts index ff1c1efb7a..1f91c2f412 100644 --- a/CommonUI/src/Utils/Telemetry.ts +++ b/CommonUI/src/Utils/Telemetry.ts @@ -17,7 +17,10 @@ import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xm export default class Telemetry { public static init(data: { serviceName: string }): void { - if (OpenTelemetryExporterOtlpEndpoint) { + const hasHeaders: boolean = + Object.keys(OpenTelemetryExporterOtlpHeaders).length > 0; + + if (OpenTelemetryExporterOtlpEndpoint && hasHeaders) { const providerConfig: TracerConfig = { resource: new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: data.serviceName, diff --git a/HelmChart/Public/oneuptime/templates/_helpers.tpl b/HelmChart/Public/oneuptime/templates/_helpers.tpl index ab934ef028..6d7c2acae0 100644 --- a/HelmChart/Public/oneuptime/templates/_helpers.tpl +++ b/HelmChart/Public/oneuptime/templates/_helpers.tpl @@ -66,6 +66,8 @@ value: {{ printf "false" | squote }} - name: STATUS_PAGE_CNAME_RECORD value: {{ $.Values.statusPage.cnameRecord }} +- name: OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT + value: {{ $.Values.openTelemetryExporter.endpoint.client }} {{- end }} {{- define "oneuptime.env.oneuptimeSecret" }} @@ -84,8 +86,9 @@ - name: IS_SERVER value: {{ printf "true" | squote }} +- name: OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT + value: {{ $.Values.openTelemetryExporter.endpoint.server }} - - name: ENCRYPTION_SECRET {{- if $.Values.encryptionSecret }} value: {{ $.Values.encryptionSecret }} diff --git a/HelmChart/Public/oneuptime/templates/accounts.yaml b/HelmChart/Public/oneuptime/templates/accounts.yaml index 267d7fb65a..5716d6bd6e 100644 --- a/HelmChart/Public/oneuptime/templates/accounts.yaml +++ b/HelmChart/Public/oneuptime/templates/accounts.yaml @@ -1,5 +1,5 @@ # OneUptime accounts Deployment -{{- $accountsEnv := dict "PORT" $.Values.port.accounts -}} +{{- $accountsEnv := dict "OPENTELEMETRY_EXPORTER_OTLP_HEADERS" $.Values.openTelemetryExporter.headers.accounts "PORT" $.Values.port.accounts -}} {{- $accountsDeploymentArgs :=dict "IsUI" true "ServiceName" "accounts" "Port" $.Values.port.accounts "Release" $.Release "Values" $.Values "Env" $accountsEnv -}} {{- include "oneuptime.deployment" $accountsDeploymentArgs }} --- diff --git a/HelmChart/Public/oneuptime/templates/admin-dashboard.yaml b/HelmChart/Public/oneuptime/templates/admin-dashboard.yaml index 54db0fb46a..c89efd0629 100644 --- a/HelmChart/Public/oneuptime/templates/admin-dashboard.yaml +++ b/HelmChart/Public/oneuptime/templates/admin-dashboard.yaml @@ -1,5 +1,5 @@ # OneUptime adminDashboard Deployment -{{- $adminDashboardEnv := dict "PORT" $.Values.port.adminDashboard -}} +{{- $adminDashboardEnv := dict "OPENTELEMETRY_EXPORTER_OTLP_HEADERS" $.Values.openTelemetryExporter.headers.adminDashboard "PORT" $.Values.port.adminDashboard -}} {{- $adminDashboardDeploymentArgs :=dict "IsUI" true "ServiceName" "admin-dashboard" "Port" $.Values.port.adminDashboard "Release" $.Release "Values" $.Values "Env" $adminDashboardEnv -}} {{- include "oneuptime.deployment" $adminDashboardDeploymentArgs }} --- diff --git a/HelmChart/Public/oneuptime/templates/app.yaml b/HelmChart/Public/oneuptime/templates/app.yaml index aca8985a49..f0bac190f3 100644 --- a/HelmChart/Public/oneuptime/templates/app.yaml +++ b/HelmChart/Public/oneuptime/templates/app.yaml @@ -1,5 +1,5 @@ # OneUptime app Deployment -{{- $appEnv := dict "PORT" $.Values.port.app "SMS_HIGH_RISK_COST_IN_CENTS" $.Values.billing.smsHighRiskValueInCents "CALL_HIGH_RISK_COST_IN_CENTS_PER_MINUTE" $.Values.billing.callHighRiskValueInCentsPerMinute "SMS_DEFAULT_COST_IN_CENTS" $.Values.billing.smsDefaultValueInCents "CALL_DEFAULT_COST_IN_CENTS_PER_MINUTE" $.Values.billing.callDefaultValueInCentsPerMinute "INTERNAL_SMTP_FROM_NAME" $.Values.internalSmtp.name "INTERNAL_SMTP_EMAIL" $.Values.internalSmtp.email "INTERNAL_SMTP_PASSWORD" "internal_smtp_password" -}} +{{- $appEnv := dict "OPENTELEMETRY_EXPORTER_OTLP_HEADERS" $.Values.openTelemetryExporter.headers.app "PORT" $.Values.port.app "SMS_HIGH_RISK_COST_IN_CENTS" $.Values.billing.smsHighRiskValueInCents "CALL_HIGH_RISK_COST_IN_CENTS_PER_MINUTE" $.Values.billing.callHighRiskValueInCentsPerMinute "SMS_DEFAULT_COST_IN_CENTS" $.Values.billing.smsDefaultValueInCents "CALL_DEFAULT_COST_IN_CENTS_PER_MINUTE" $.Values.billing.callDefaultValueInCentsPerMinute "INTERNAL_SMTP_FROM_NAME" $.Values.internalSmtp.name "INTERNAL_SMTP_EMAIL" $.Values.internalSmtp.email "INTERNAL_SMTP_PASSWORD" "internal_smtp_password" -}} {{- $appDeploymentArgs :=dict "IsServer" true "ServiceName" "app" "Port" $.Values.port.app "Release" $.Release "Values" $.Values "Env" $appEnv -}} {{- include "oneuptime.deployment" $appDeploymentArgs }} --- diff --git a/HelmChart/Public/oneuptime/templates/dashboard.yaml b/HelmChart/Public/oneuptime/templates/dashboard.yaml index 433ed46a04..072f0674f2 100644 --- a/HelmChart/Public/oneuptime/templates/dashboard.yaml +++ b/HelmChart/Public/oneuptime/templates/dashboard.yaml @@ -1,5 +1,5 @@ # OneUptime dashboard Deployment -{{- $dashboardEnv := dict "PORT" $.Values.port.dashboard -}} +{{- $dashboardEnv := dict "OPENTELEMETRY_EXPORTER_OTLP_HEADERS" $.Values.openTelemetryExporter.headers.dashboard "PORT" $.Values.port.dashboard -}} {{- $dashboardDeploymentArgs :=dict "IsUI" true "ServiceName" "dashboard" "Port" $.Values.port.dashboard "Release" $.Release "Values" $.Values "Env" $dashboardEnv -}} {{- include "oneuptime.deployment" $dashboardDeploymentArgs }} --- diff --git a/HelmChart/Public/oneuptime/templates/probe.yaml b/HelmChart/Public/oneuptime/templates/probe.yaml index d83130c05d..ed6a01f7c5 100644 --- a/HelmChart/Public/oneuptime/templates/probe.yaml +++ b/HelmChart/Public/oneuptime/templates/probe.yaml @@ -28,6 +28,8 @@ spec: env: - name: PORT value: {{ $.Values.port.probe | squote }} + - name: OPENTELEMETRY_EXPORTER_OTLP_HEADERS + value: {{ $.Values.openTelemetryExporter.headers.probe }} - name: ONEUPTIME_URL value: http://{{ $.Release.Name }}-ingestor.{{ $.Release.Namespace }}.svc.{{ $.Values.global.clusterDomain }}:{{ $.Values.port.ingestor }} - name: PROBE_NAME diff --git a/HelmChart/Public/oneuptime/templates/status-page.yaml b/HelmChart/Public/oneuptime/templates/status-page.yaml index ea3daeb023..c9b2f1afb2 100644 --- a/HelmChart/Public/oneuptime/templates/status-page.yaml +++ b/HelmChart/Public/oneuptime/templates/status-page.yaml @@ -1,5 +1,5 @@ # OneUptime statusPage Deployment -{{- $statusPageEnv := dict "PORT" $.Values.port.statusPage -}} +{{- $statusPageEnv := dict "OPENTELEMETRY_EXPORTER_OTLP_HEADERS" $.Values.openTelemetryExporter.headers.statusPage "PORT" $.Values.port.statusPage -}} {{- $statusPageDeploymentArgs :=dict "IsUI" true "ServiceName" "status-page" "Port" $.Values.port.statusPage "Release" $.Release "Values" $.Values "Env" $statusPageEnv -}} {{- include "oneuptime.deployment" $statusPageDeploymentArgs }} --- diff --git a/HelmChart/Public/oneuptime/values.yaml b/HelmChart/Public/oneuptime/values.yaml index 0baa8427fe..1047515936 100644 --- a/HelmChart/Public/oneuptime/values.yaml +++ b/HelmChart/Public/oneuptime/values.yaml @@ -138,15 +138,8 @@ probes: port: app: 3002 - workflow: 3099 - alert: 3088 ingestor: 3400 testServer: 3800 - file: 3125 - identity: 3087 - notification: 3191 - realtime: 3300 - workers: 3452 accounts: 3003 statusPage: 3105 dashboard: 3009 @@ -162,5 +155,15 @@ testServer: enabled: false -openTelemetry: +openTelemetryExporter: + endpoint: + server: + client: + headers: + app: + dashboard: + accounts: + statusPage: + probe: + adminDashboard: \ No newline at end of file