File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
packages/core/src/telemetry Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -240,17 +240,21 @@ export async function initializeTelemetry(
240240 } ) ;
241241 } else if ( useOtlp ) {
242242 if ( otlpProtocol === 'http' ) {
243- // Trim trailing slashes
244- const baseUrl = parsedEndpoint . replace ( / \/ + $ / , '' ) ;
243+ const buildUrl = ( path : string ) => {
244+ const url = new URL ( parsedEndpoint ) ;
245+ // Join the existing pathname with the new path, handling trailing slashes.
246+ url . pathname = [ url . pathname . replace ( / \/ $ / , '' ) , path ] . join ( '/' ) ;
247+ return url . href ;
248+ } ;
245249 spanExporter = new OTLPTraceExporterHttp ( {
246- url : ` ${ baseUrl } / v1/traces` ,
250+ url : buildUrl ( ' v1/traces' ) ,
247251 } ) ;
248252 logExporter = new OTLPLogExporterHttp ( {
249- url : ` ${ baseUrl } / v1/logs` ,
253+ url : buildUrl ( ' v1/logs' ) ,
250254 } ) ;
251255 metricReader = new PeriodicExportingMetricReader ( {
252256 exporter : new OTLPMetricExporterHttp ( {
253- url : ` ${ baseUrl } / v1/metrics` ,
257+ url : buildUrl ( ' v1/metrics' ) ,
254258 } ) ,
255259 exportIntervalMillis : 10000 ,
256260 } ) ;
You can’t perform that action at this time.
0 commit comments