Refactor Telemetry and TelemetryIngest classes to use URL class from Common/Types/API/URL

This commit is contained in:
Simon Larsen 2024-07-09 20:02:12 +01:00
parent 34118d5892
commit 0c7db14e99
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
2 changed files with 3 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import {
WebTracerProvider,
} from "@opentelemetry/sdk-trace-web";
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
import URL from "Common/Types/API/URL";
export default class Telemetry {
public static init(data: { serviceName: string }): void {
@ -32,7 +33,7 @@ export default class Telemetry {
provider.addSpanProcessor(
new BatchSpanProcessor(
new OTLPTraceExporter({
url: OpenTelemetryExporterOtlpEndpoint?.toString() + "/v1/traces",
url: URL.fromString(OpenTelemetryExporterOtlpEndpoint?.toString() + "/v1/traces").toString(),
headers: OpenTelemetryExporterOtlpHeaders,
}),
),

View File

@ -62,7 +62,7 @@ export default class TelemetryIngest {
});
if (!service) {
throw new BadRequestException("Invalid service token");
throw new BadRequestException("Invalid service token: "+serviceTokenInHeader);
}
(req as TelemetryRequest).serviceId = service.id as ObjectID;