File tree 1 file changed +16
-5
lines changed
1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ use opentelemetry_sdk::{
14
14
trace:: { RandomIdGenerator , Sampler , TracerProvider } ,
15
15
Resource ,
16
16
} ;
17
+ use url:: Url ;
17
18
18
19
use std:: env;
19
20
use std:: fs:: File ;
@@ -222,11 +223,21 @@ impl LoggingOpts {
222
223
. with_timeout ( * timeout)
223
224
. with_metadata ( metadata_map. clone ( ) )
224
225
. build ( ) ,
225
- OtelProtocol :: Http => SpanExporter :: builder ( )
226
- . with_http ( )
227
- . with_endpoint ( endpoint)
228
- . with_timeout ( * timeout)
229
- . build ( ) ,
226
+ OtelProtocol :: Http => {
227
+ // with_endpoint() is _roughly_ equivalent to using the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env var
228
+ // So we have to append the `v1/traces` to the base URL when using http
229
+ // https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_traces_endpoint
230
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
231
+ let url = Url :: parse ( endpoint)
232
+ . expect ( "Expected a valid URI" )
233
+ . join ( "v1/traces" )
234
+ . unwrap ( ) ;
235
+ SpanExporter :: builder ( )
236
+ . with_http ( )
237
+ . with_endpoint ( url)
238
+ . with_timeout ( * timeout)
239
+ . build ( )
240
+ }
230
241
} ;
231
242
232
243
let tracer = TracerProvider :: builder ( )
You can’t perform that action at this time.
0 commit comments