File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 11use std:: time:: Duration ;
22
33use anyhow:: { bail, Result } ;
4+ use opentelemetry:: global;
45use opentelemetry_otlp:: MetricsExporterBuilder ;
56use opentelemetry_sdk:: {
67 metrics:: {
@@ -57,6 +58,8 @@ pub(crate) fn otel_metrics_layer<S: Subscriber + for<'span> LookupSpan<'span>>(
5758 . with_resource ( resource)
5859 . build ( ) ;
5960
61+ global:: set_meter_provider ( meter_provider. clone ( ) ) ;
62+
6063 Ok ( MetricsLayer :: new ( meter_provider) )
6164}
6265
Original file line number Diff line number Diff line change 11use std:: time:: Duration ;
22
33use anyhow:: bail;
4- use opentelemetry:: trace:: TracerProvider ;
4+ use opentelemetry:: { global , trace:: TracerProvider } ;
55use opentelemetry_otlp:: SpanExporterBuilder ;
66use opentelemetry_sdk:: {
77 resource:: { EnvResourceDetector , TelemetryResourceDetector } ,
@@ -35,18 +35,20 @@ pub(crate) fn otel_tracing_layer<S: Subscriber + for<'span> LookupSpan<'span>>(
3535 ) ;
3636
3737 // This will configure the exporter based on the OTEL_EXPORTER_* environment variables.
38- let exporter : SpanExporterBuilder = match OtlpProtocol :: traces_protocol_from_env ( ) {
38+ let exporter_builder : SpanExporterBuilder = match OtlpProtocol :: traces_protocol_from_env ( ) {
3939 OtlpProtocol :: Grpc => opentelemetry_otlp:: new_exporter ( ) . tonic ( ) . into ( ) ,
4040 OtlpProtocol :: HttpProtobuf => opentelemetry_otlp:: new_exporter ( ) . http ( ) . into ( ) ,
4141 OtlpProtocol :: HttpJson => bail ! ( "http/json OTLP protocol is not supported" ) ,
4242 } ;
4343
4444 let tracer_provider = opentelemetry_otlp:: new_pipeline ( )
4545 . tracing ( )
46- . with_exporter ( exporter )
46+ . with_exporter ( exporter_builder )
4747 . with_trace_config ( opentelemetry_sdk:: trace:: Config :: default ( ) . with_resource ( resource) )
4848 . install_batch ( opentelemetry_sdk:: runtime:: Tokio ) ?;
4949
50+ global:: set_tracer_provider ( tracer_provider. clone ( ) ) ;
51+
5052 let env_filter = match EnvFilter :: try_from_env ( "SPIN_OTEL_TRACING_LEVEL" ) {
5153 Ok ( filter) => filter,
5254 // If it isn't set or it fails to parse default to info
You can’t perform that action at this time.
0 commit comments