File tree Expand file tree Collapse file tree
packages/core/src/telemetry Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,13 +113,13 @@ describe('Telemetry SDK', () => {
113113 await initializeTelemetry ( mockConfig ) ;
114114
115115 expect ( OTLPTraceExporterHttp ) . toHaveBeenCalledWith ( {
116- url : 'http://localhost:4318/' ,
116+ url : 'http://localhost:4318/v1/traces ' ,
117117 } ) ;
118118 expect ( OTLPLogExporterHttp ) . toHaveBeenCalledWith ( {
119- url : 'http://localhost:4318/' ,
119+ url : 'http://localhost:4318/v1/logs ' ,
120120 } ) ;
121121 expect ( OTLPMetricExporterHttp ) . toHaveBeenCalledWith ( {
122- url : 'http://localhost:4318/' ,
122+ url : 'http://localhost:4318/v1/metrics ' ,
123123 } ) ;
124124 expect ( NodeSDK . prototype . start ) . toHaveBeenCalled ( ) ;
125125 } ) ;
@@ -141,7 +141,7 @@ describe('Telemetry SDK', () => {
141141 ) ;
142142 await initializeTelemetry ( mockConfig ) ;
143143 expect ( OTLPTraceExporterHttp ) . toHaveBeenCalledWith (
144- expect . objectContaining ( { url : 'https://my-collector.com/' } ) ,
144+ expect . objectContaining ( { url : 'https://my-collector.com/v1/traces ' } ) ,
145145 ) ;
146146 } ) ;
147147
Original file line number Diff line number Diff line change @@ -275,15 +275,21 @@ export async function initializeTelemetry(
275275 } ) ;
276276 } else if ( useOtlp ) {
277277 if ( otlpProtocol === 'http' ) {
278+ const buildUrl = ( path : string ) => {
279+ const url = new URL ( parsedEndpoint ) ;
280+ // Join the existing pathname with the new path, handling trailing slashes.
281+ url . pathname = [ url . pathname . replace ( / \/ $ / , '' ) , path ] . join ( '/' ) ;
282+ return url . href ;
283+ } ;
278284 spanExporter = new OTLPTraceExporterHttp ( {
279- url : parsedEndpoint ,
285+ url : buildUrl ( 'v1/traces' ) ,
280286 } ) ;
281287 logExporter = new OTLPLogExporterHttp ( {
282- url : parsedEndpoint ,
288+ url : buildUrl ( 'v1/logs' ) ,
283289 } ) ;
284290 metricReader = new PeriodicExportingMetricReader ( {
285291 exporter : new OTLPMetricExporterHttp ( {
286- url : parsedEndpoint ,
292+ url : buildUrl ( 'v1/metrics' ) ,
287293 } ) ,
288294 exportIntervalMillis : 10000 ,
289295 } ) ;
You can’t perform that action at this time.
0 commit comments