Update telemetry environment variables

This commit is contained in:
Simon Larsen 2024-02-22 17:07:33 +00:00
parent 5dc625c34b
commit 17fbae7cd5
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
3 changed files with 11 additions and 10 deletions

View File

@ -31,12 +31,12 @@ export default class OneUptimeTelemetry {
public static logger: Logger | null = null; public static logger: Logger | null = null;
public static getHeaders(): Dictionary<string> { public static getHeaders(): Dictionary<string> {
if (!process.env['OTEL_EXPORTER_OTLP_HEADERS']) { if (!process.env['OPENTELEMETRY_EXPORTER_OTLP_HEADERS']) {
return {}; return {};
} }
const headersStrings: Array<string> = const headersStrings: Array<string> =
process.env['OTEL_EXPORTER_OTLP_HEADERS'].split(';'); process.env['OPENTELEMETRY_EXPORTER_OTLP_HEADERS'].split(';');
const headers: Dictionary<string> = {}; const headers: Dictionary<string> = {};
@ -51,11 +51,11 @@ export default class OneUptimeTelemetry {
} }
public static getOtlpEndpoint(): URL | null { public static getOtlpEndpoint(): URL | null {
if (!process.env['OTEL_EXPORTER_OTLP_ENDPOINT']) { if (!process.env['OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT']) {
return null; return null;
} }
return URL.fromString(process.env['OTEL_EXPORTER_OTLP_ENDPOINT'] || ''); return URL.fromString(process.env['OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT'] || '');
} }
public static getOltpLogsEndpoint(): URL | null { public static getOltpLogsEndpoint(): URL | null {
@ -113,6 +113,8 @@ export default class OneUptimeTelemetry {
traceExporter = new OTLPTraceExporter({ traceExporter = new OTLPTraceExporter({
url: this.getOltpTracesEndpoint()!.toString(), url: this.getOltpTracesEndpoint()!.toString(),
headers: headers, headers: headers,
compression: CompressionAlgorithm.GZIP,
}); });
} }
@ -121,6 +123,7 @@ export default class OneUptimeTelemetry {
exporter: new OTLPMetricExporter({ exporter: new OTLPMetricExporter({
url: this.getOltpMetricsEndpoint()!.toString(), url: this.getOltpMetricsEndpoint()!.toString(),
headers: headers, headers: headers,
compression: CompressionAlgorithm.GZIP,
}), }),
}); });
} }
@ -131,7 +134,7 @@ export default class OneUptimeTelemetry {
const logExporter: OTLPLogExporter = new OTLPLogExporter({ const logExporter: OTLPLogExporter = new OTLPLogExporter({
url: this.getOltpLogsEndpoint()!.toString(), url: this.getOltpLogsEndpoint()!.toString(),
headers: headers, headers: headers,
compression: CompressionAlgorithm.GZIP, compression: CompressionAlgorithm.GZIP,
}); });
loggerProvider.addLogRecordProcessor( loggerProvider.addLogRecordProcessor(

View File

@ -62,9 +62,7 @@ class OpenTelemetryRequestMiddleware {
): Promise<void> { ): Promise<void> {
try { try {
let productType: ProductType; let productType: ProductType;
debugger;
const isProtobuf: boolean = req.body instanceof Uint8Array; const isProtobuf: boolean = req.body instanceof Uint8Array;
if (req.url.includes('/otlp/v1/traces')) { if (req.url.includes('/otlp/v1/traces')) {

View File

@ -234,8 +234,8 @@ services:
INTERNAL_SMTP_EMAIL: ${INTERNAL_SMTP_EMAIL} INTERNAL_SMTP_EMAIL: ${INTERNAL_SMTP_EMAIL}
INTERNAL_SMTP_FROM_NAME: ${INTERNAL_SMTP_FROM_NAME} INTERNAL_SMTP_FROM_NAME: ${INTERNAL_SMTP_FROM_NAME}
INTERNAL_SMTP_PASSWORD: ${INTERNAL_SMTP_PASSWORD} INTERNAL_SMTP_PASSWORD: ${INTERNAL_SMTP_PASSWORD}
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT} OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT}
OTEL_EXPORTER_OTLP_HEADERS: ${APP_OTEL_EXPORTER_OTLP_HEADERS} OPENTELEMETRY_EXPORTER_OTLP_HEADERS: ${APP_OTEL_EXPORTER_OTLP_HEADERS}
depends_on: depends_on:
- redis - redis
- postgres - postgres