From ccb960f30ee24b4e052fe2f6252a9548b24851d5 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Fri, 23 Feb 2024 13:25:15 +0000 Subject: [PATCH] Fix formatting issues and update dependencies --- Common/Types/Text.ts | 5 ++--- CommonUI/src/Utils/Telemetry.ts | 16 +++++++--------- Ingestor/API/OTelIngest.ts | 20 +++++++++++++++----- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Common/Types/Text.ts b/Common/Types/Text.ts index 051fd65c26..8e2f2e52dd 100644 --- a/Common/Types/Text.ts +++ b/Common/Types/Text.ts @@ -4,7 +4,7 @@ export default class Text { return textInBase64; } - if(!this.isBase64(textInBase64)) { + if (!this.isBase64(textInBase64)) { return textInBase64; } @@ -14,10 +14,9 @@ export default class Text { const hex: string = raw.charCodeAt(i).toString(16); result += hex.length === 2 ? hex : '0' + hex; } - return result.toUpperCase(); + return result; } - public static isBase64(text: string): boolean { const regex: RegExp = /^[a-zA-Z0-9+/]*={0,2}$/; return regex.test(text); diff --git a/CommonUI/src/Utils/Telemetry.ts b/CommonUI/src/Utils/Telemetry.ts index 1965892001..6af70cb58a 100644 --- a/CommonUI/src/Utils/Telemetry.ts +++ b/CommonUI/src/Utils/Telemetry.ts @@ -1,5 +1,4 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation'; -import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web'; import { BatchSpanProcessor, TracerConfig, @@ -13,6 +12,8 @@ import { OpenTelemetryExporterOtlpEndpoint, OpenTelemetryExporterOtlpHeaders, } from '../Config'; +import {FetchInstrumentation} from '@opentelemetry/instrumentation-fetch'; +import { XMLHttpRequestInstrumentation } from "@opentelemetry/instrumentation-xml-http-request"; const providerConfig: TracerConfig = { resource: new Resource({ @@ -29,7 +30,9 @@ if (OpenTelemetryExporterOtlpEndpoint) { provider.addSpanProcessor( new BatchSpanProcessor( new OTLPTraceExporter({ - url: OpenTelemetryExporterOtlpEndpoint?.toString() + '/v1/traces', + url: + OpenTelemetryExporterOtlpEndpoint?.toString() + + '/v1/traces', headers: OpenTelemetryExporterOtlpHeaders, }) ) @@ -42,12 +45,7 @@ provider.register({ registerInstrumentations({ instrumentations: [ - // getWebAutoInstrumentations initializes all the package. - // it's possible to configure each instrumentation if needed. - getWebAutoInstrumentations({ - '@opentelemetry/instrumentation-fetch': { - enabled: true, - }, - }), + new FetchInstrumentation(), + new XMLHttpRequestInstrumentation() ], }); diff --git a/Ingestor/API/OTelIngest.ts b/Ingestor/API/OTelIngest.ts index 0c559b365d..63080180f0 100644 --- a/Ingestor/API/OTelIngest.ts +++ b/Ingestor/API/OTelIngest.ts @@ -135,9 +135,15 @@ router.post( dbSpan.projectId = (req as TelemetryRequest).projectId; dbSpan.serviceId = (req as TelemetryRequest).serviceId; - dbSpan.spanId = Text.convertBase64ToHex(span['spanId'] as string); - dbSpan.traceId = Text.convertBase64ToHex(span['traceId'] as string); - dbSpan.parentSpanId = Text.convertBase64ToHex(span['parentSpanId'] as string); + dbSpan.spanId = Text.convertBase64ToHex( + span['spanId'] as string + ); + dbSpan.traceId = Text.convertBase64ToHex( + span['traceId'] as string + ); + dbSpan.parentSpanId = Text.convertBase64ToHex( + span['parentSpanId'] as string + ); dbSpan.startTimeUnixNano = span[ 'startTimeUnixNano' ] as number; @@ -575,8 +581,12 @@ router.post( dbLog.body = logBody['stringValue'] as string; - dbLog.traceId = Text.convertBase64ToHex(log['traceId'] as string); - dbLog.spanId = Text.convertBase64ToHex(log['spanId'] as string); + dbLog.traceId = Text.convertBase64ToHex( + log['traceId'] as string + ); + dbLog.spanId = Text.convertBase64ToHex( + log['spanId'] as string + ); // We need to convert this to date. dbLog.attributes = OTelIngestService.getKeyValues(