Fix formatting issues and update dependencies

This commit is contained in:
Simon Larsen 2024-02-23 13:25:15 +00:00
parent 07ab132946
commit ccb960f30e
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
3 changed files with 24 additions and 17 deletions

View File

@ -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);

View File

@ -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()
],
});

View File

@ -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(