File tree Expand file tree Collapse file tree
init-tracing-opentelemetry/src/otlp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,9 +16,12 @@ pub fn init_loggerprovider<F>(
1616where
1717 F : FnOnce ( LoggerProviderBuilder ) -> LoggerProviderBuilder ,
1818{
19- let ( maybe_protocol, maybe_endpoint) = read_protocol_and_endpoint_from_env ( ) ;
20- let protocol = infer_protocol ( maybe_protocol. as_deref ( ) , maybe_endpoint. as_deref ( ) ) ;
19+ let protocol = {
20+ let ( maybe_protocol, maybe_endpoint) = read_protocol_and_endpoint_from_env ( ) ;
21+ infer_protocol ( maybe_protocol. as_deref ( ) , maybe_endpoint. as_deref ( ) )
22+ } ;
2123
24+ // builders used the environment variables to determine the endpoint (but not to setup the protocol)
2225 let exporter: Option < LogExporter > = match protocol. as_deref ( ) {
2326 Some ( "http/protobuf" ) => Some ( LogExporter :: builder ( ) . with_http ( ) . build ( ) ?) ,
2427 #[ cfg( feature = "tls" ) ]
Original file line number Diff line number Diff line change @@ -21,8 +21,10 @@ pub fn init_meterprovider<F>(
2121where
2222 F : FnOnce ( MeterProviderBuilder ) -> MeterProviderBuilder ,
2323{
24- let ( maybe_protocol, maybe_endpoint) = read_protocol_and_endpoint_from_env ( ) ;
25- let protocol = infer_protocol ( maybe_protocol. as_deref ( ) , maybe_endpoint. as_deref ( ) ) ;
24+ let protocol = {
25+ let ( maybe_protocol, maybe_endpoint) = read_protocol_and_endpoint_from_env ( ) ;
26+ infer_protocol ( maybe_protocol. as_deref ( ) , maybe_endpoint. as_deref ( ) )
27+ } ;
2628 let timeout = env:: var ( "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT" )
2729 . ok ( )
2830 . and_then ( |var| var. parse :: < u64 > ( ) . ok ( ) )
4345 . and_then ( |var| var. parse :: < u64 > ( ) . ok ( ) )
4446 . map_or ( Duration :: from_secs ( 60 ) , Duration :: from_millis) ;
4547
48+ // builders used the environment variables to determine the endpoint (but not to setup the protocol)
4649 let exporter = match protocol. as_deref ( ) {
4750 Some ( "http/protobuf" ) => Some (
4851 MetricExporter :: builder ( )
Original file line number Diff line number Diff line change 1818 F : FnOnce ( TracerProviderBuilder ) -> TracerProviderBuilder ,
1919{
2020 debug_env ( ) ;
21- let ( maybe_protocol, maybe_endpoint) = read_protocol_and_endpoint_from_env ( ) ;
22- let protocol = infer_protocol ( maybe_protocol. as_deref ( ) , maybe_endpoint. as_deref ( ) ) ;
21+ let protocol = {
22+ let ( maybe_protocol, maybe_endpoint) = read_protocol_and_endpoint_from_env ( ) ;
23+ infer_protocol ( maybe_protocol. as_deref ( ) , maybe_endpoint. as_deref ( ) )
24+ } ;
2325
26+ // builders used the environment variables to determine the endpoint (but not to setup the protocol)
2427 let exporter: Option < SpanExporter > = match protocol. as_deref ( ) {
2528 Some ( "http/protobuf" ) => Some ( SpanExporter :: builder ( ) . with_http ( ) . build ( ) ?) ,
2629 #[ cfg( feature = "tls" ) ]
You can’t perform that action at this time.
0 commit comments