diff --git a/examples/hyper-prometheus/src/main.rs b/examples/hyper-prometheus/src/main.rs index 4c1839a50d..ec7472c37c 100644 --- a/examples/hyper-prometheus/src/main.rs +++ b/examples/hyper-prometheus/src/main.rs @@ -76,7 +76,7 @@ pub async fn main() -> Result<(), Box> { let provider = MeterProvider::builder().with_reader(exporter).build(); let cx = Context::new(); - let meter = provider.meter("hyper-prometheus-example"); + let meter = provider.meter("hyper-prometheus-example".into()); let state = Arc::new(AppState { registry, http_counter: meter diff --git a/opentelemetry-api/src/global/metrics.rs b/opentelemetry-api/src/global/metrics.rs index 53fcbfcf43..dd0ad5c311 100644 --- a/opentelemetry-api/src/global/metrics.rs +++ b/opentelemetry-api/src/global/metrics.rs @@ -1,7 +1,10 @@ use crate::metrics::{self, Meter, MeterProvider}; use core::fmt; use once_cell::sync::Lazy; -use std::sync::{Arc, RwLock}; +use std::{ + borrow::Cow, + sync::{Arc, RwLock}, +}; /// The global `Meter` provider singleton. static GLOBAL_METER_PROVIDER: Lazy> = Lazy::new(|| { @@ -26,9 +29,9 @@ impl fmt::Debug for GlobalMeterProvider { impl MeterProvider for GlobalMeterProvider { fn versioned_meter( &self, - name: &'static str, - version: Option<&'static str>, - schema_url: Option<&'static str>, + name: Cow<'static, str>, + version: Option>, + schema_url: Option>, ) -> Meter { self.provider.versioned_meter(name, version, schema_url) } @@ -72,8 +75,8 @@ pub fn meter_provider() -> GlobalMeterProvider { /// If the name is an empty string, the provider will use a default name. /// /// This is a more convenient way of expressing `global::meter_provider().meter(name, None, None)`. -pub fn meter(name: &'static str) -> Meter { - meter_provider().versioned_meter(name, None, None) +pub fn meter(name: impl Into>) -> Meter { + meter_provider().versioned_meter(name.into(), None, None) } /// Creates a [`Meter`] with the name, version and schema url. @@ -86,13 +89,13 @@ pub fn meter(name: &'static str) -> Meter { /// # Example /// ```rust /// use opentelemetry_api::global::meter_with_version; -/// let meter = meter_with_version("io.opentelemetry", Some("0.17"), Some("https://opentelemetry.io/schemas/1.2.0")); +/// let meter = meter_with_version("io.opentelemetry", Some("0.17".into()), Some("https://opentelemetry.io/schemas/1.2.0".into())); /// ``` /// pub fn meter_with_version( - name: &'static str, - version: Option<&'static str>, - schema_url: Option<&'static str>, + name: impl Into>, + version: Option>, + schema_url: Option>, ) -> Meter { - meter_provider().versioned_meter(name, version, schema_url) + meter_provider().versioned_meter(name.into(), version, schema_url) } diff --git a/opentelemetry-api/src/global/mod.rs b/opentelemetry-api/src/global/mod.rs index 89a94e7524..b546bd65be 100644 --- a/opentelemetry-api/src/global/mod.rs +++ b/opentelemetry-api/src/global/mod.rs @@ -57,8 +57,8 @@ //! // End users of your library will configure their global tracer provider //! // so you can use the global tracer without any setup //! let tracer = global::tracer_provider().versioned_tracer( -//! "my-library-name", -//! Some(env!("CARGO_PKG_VERSION")), +//! "my-library-name".into(), +//! Some(env!("CARGO_PKG_VERSION").into()), //! None, //! ); //! diff --git a/opentelemetry-api/src/global/trace.rs b/opentelemetry-api/src/global/trace.rs index 260c5a68bd..9ad2672c2f 100644 --- a/opentelemetry-api/src/global/trace.rs +++ b/opentelemetry-api/src/global/trace.rs @@ -291,8 +291,8 @@ pub trait ObjectSafeTracerProvider { fn versioned_tracer_boxed( &self, name: Cow<'static, str>, - version: Option<&'static str>, - schema_url: Option<&'static str>, + version: Option>, + schema_url: Option>, ) -> Box; } @@ -306,8 +306,8 @@ where fn versioned_tracer_boxed( &self, name: Cow<'static, str>, - version: Option<&'static str>, - schema_url: Option<&'static str>, + version: Option>, + schema_url: Option>, ) -> Box { Box::new(self.versioned_tracer(name, version, schema_url)) } @@ -349,13 +349,13 @@ impl trace::TracerProvider for GlobalTracerProvider { /// Create a versioned tracer using the global provider. fn versioned_tracer( &self, - name: impl Into>, - version: Option<&'static str>, - schema_url: Option<&'static str>, + name: Cow<'static, str>, + version: Option>, + schema_url: Option>, ) -> Self::Tracer { BoxedTracer( self.provider - .versioned_tracer_boxed(name.into(), version, schema_url), + .versioned_tracer_boxed(name, version, schema_url), ) } } diff --git a/opentelemetry-api/src/metrics/meter.rs b/opentelemetry-api/src/metrics/meter.rs index 854965d119..82c8af64ca 100644 --- a/opentelemetry-api/src/metrics/meter.rs +++ b/opentelemetry-api/src/metrics/meter.rs @@ -22,7 +22,7 @@ pub trait MeterProvider { /// /// If the name is empty, then an implementation defined default name will /// be used instead. - fn meter(&self, name: &'static str) -> Meter { + fn meter(&self, name: Cow<'static, str>) -> Meter { self.versioned_meter(name, None, None) } @@ -34,9 +34,9 @@ pub trait MeterProvider { /// default name will be used instead. fn versioned_meter( &self, - name: &'static str, - version: Option<&'static str>, - schema_url: Option<&'static str>, + name: Cow<'static, str>, + version: Option>, + schema_url: Option>, ) -> Meter; } diff --git a/opentelemetry-api/src/metrics/noop.rs b/opentelemetry-api/src/metrics/noop.rs index baf3627e9f..c865158764 100644 --- a/opentelemetry-api/src/metrics/noop.rs +++ b/opentelemetry-api/src/metrics/noop.rs @@ -10,7 +10,7 @@ use crate::{ }, Context, KeyValue, }; -use std::{any::Any, sync::Arc}; +use std::{any::Any, borrow::Cow, sync::Arc}; /// A no-op instance of a `MetricProvider` #[derive(Debug, Default)] @@ -28,9 +28,9 @@ impl NoopMeterProvider { impl MeterProvider for NoopMeterProvider { fn versioned_meter( &self, - _name: &'static str, - _version: Option<&'static str>, - _schema_url: Option<&'static str>, + _name: Cow<'static, str>, + _version: Option>, + _schema_url: Option>, ) -> Meter { Meter::new(Arc::new(NoopMeterCore::new())) } diff --git a/opentelemetry-api/src/trace/mod.rs b/opentelemetry-api/src/trace/mod.rs index 1d51b82567..5f7d934f3c 100644 --- a/opentelemetry-api/src/trace/mod.rs +++ b/opentelemetry-api/src/trace/mod.rs @@ -52,8 +52,8 @@ //! //! // Get a tracer for this library //! let tracer = tracer_provider.versioned_tracer( -//! "my_name", -//! Some(env!("CARGO_PKG_VERSION")), +//! "my_name".into(), +//! Some(env!("CARGO_PKG_VERSION").into()), //! None //! ); //! diff --git a/opentelemetry-api/src/trace/noop.rs b/opentelemetry-api/src/trace/noop.rs index 2af3e13cfc..613ef95cf7 100644 --- a/opentelemetry-api/src/trace/noop.rs +++ b/opentelemetry-api/src/trace/noop.rs @@ -31,9 +31,9 @@ impl trace::TracerProvider for NoopTracerProvider { /// Returns a new `NoopTracer` instance. fn versioned_tracer( &self, - _name: impl Into>, - _version: Option<&'static str>, - _schema_url: Option<&'static str>, + _name: Cow<'static, str>, + _version: Option>, + _schema_url: Option>, ) -> Self::Tracer { NoopTracer::new() } diff --git a/opentelemetry-api/src/trace/tracer_provider.rs b/opentelemetry-api/src/trace/tracer_provider.rs index c560a3e945..cf5372d516 100644 --- a/opentelemetry-api/src/trace/tracer_provider.rs +++ b/opentelemetry-api/src/trace/tracer_provider.rs @@ -25,16 +25,16 @@ pub trait TracerProvider { /// let provider = global::tracer_provider(); /// /// // tracer used in applications/binaries - /// let tracer = provider.tracer("my_app"); + /// let tracer = provider.tracer("my_app".into()); /// /// // tracer used in libraries/crates that optionally includes version and schema url /// let tracer = provider.versioned_tracer( - /// "my_library", - /// Some(env!("CARGO_PKG_VERSION")), - /// Some("https://opentelemetry.io/schema/1.0.0") + /// "my_library".into(), + /// Some(env!("CARGO_PKG_VERSION").into()), + /// Some("https://opentelemetry.io/schema/1.0.0".into()) /// ); /// ``` - fn tracer(&self, name: impl Into>) -> Self::Tracer { + fn tracer(&self, name: Cow<'static, str>) -> Self::Tracer { self.versioned_tracer(name, None, None) } @@ -52,19 +52,19 @@ pub trait TracerProvider { /// let provider = global::tracer_provider(); /// /// // tracer used in applications/binaries - /// let tracer = provider.tracer("my_app"); + /// let tracer = provider.tracer("my_app".into()); /// /// // tracer used in libraries/crates that optionally includes version and schema url /// let tracer = provider.versioned_tracer( - /// "my_library", - /// Some(env!("CARGO_PKG_VERSION")), - /// Some("https://opentelemetry.io/schema/1.0.0") + /// "my_library".into(), + /// Some(env!("CARGO_PKG_VERSION").into()), + /// Some("https://opentelemetry.io/schema/1.0.0".into()) /// ); /// ``` fn versioned_tracer( &self, - name: impl Into>, - version: Option<&'static str>, - schema_url: Option<&'static str>, + name: Cow<'static, str>, + version: Option>, + schema_url: Option>, ) -> Self::Tracer; } diff --git a/opentelemetry-contrib/src/trace/exporter/jaeger_json.rs b/opentelemetry-contrib/src/trace/exporter/jaeger_json.rs index 4c28f31081..be11c8b257 100644 --- a/opentelemetry-contrib/src/trace/exporter/jaeger_json.rs +++ b/opentelemetry-contrib/src/trace/exporter/jaeger_json.rs @@ -45,8 +45,11 @@ impl JaegerJsonExporter { let provider = provider_builder.build(); - let tracer = - provider.versioned_tracer("opentelemetry", Some(env!("CARGO_PKG_VERSION")), None); + let tracer = provider.versioned_tracer( + "opentelemetry".into(), + Some(env!("CARGO_PKG_VERSION").into()), + None, + ); let _ = opentelemetry::global::set_tracer_provider(provider); tracer diff --git a/opentelemetry-datadog/src/exporter/mod.rs b/opentelemetry-datadog/src/exporter/mod.rs index 52838592f4..587d222da0 100644 --- a/opentelemetry-datadog/src/exporter/mod.rs +++ b/opentelemetry-datadog/src/exporter/mod.rs @@ -290,8 +290,8 @@ impl DatadogPipelineBuilder { provider_builder = provider_builder.with_config(config); let provider = provider_builder.build(); let tracer = provider.versioned_tracer( - "opentelemetry-datadog", - Some(env!("CARGO_PKG_VERSION")), + "opentelemetry-datadog".into(), + Some(env!("CARGO_PKG_VERSION").into()), None, ); let _ = global::set_tracer_provider(provider); @@ -311,8 +311,8 @@ impl DatadogPipelineBuilder { provider_builder = provider_builder.with_config(config); let provider = provider_builder.build(); let tracer = provider.versioned_tracer( - "opentelemetry-datadog", - Some(env!("CARGO_PKG_VERSION")), + "opentelemetry-datadog".into(), + Some(env!("CARGO_PKG_VERSION").into()), None, ); let _ = global::set_tracer_provider(provider); diff --git a/opentelemetry-jaeger/src/exporter/config/mod.rs b/opentelemetry-jaeger/src/exporter/config/mod.rs index 59071067ad..7c802011aa 100644 --- a/opentelemetry-jaeger/src/exporter/config/mod.rs +++ b/opentelemetry-jaeger/src/exporter/config/mod.rs @@ -121,8 +121,8 @@ pub(crate) fn install_tracer_provider_and_get_tracer( tracer_provider: sdk::trace::TracerProvider, ) -> Result { let tracer = tracer_provider.versioned_tracer( - "opentelemetry-jaeger", - Some(env!("CARGO_PKG_VERSION")), + "opentelemetry-jaeger".into(), + Some(env!("CARGO_PKG_VERSION").into()), None, ); let _ = global::set_tracer_provider(tracer_provider); diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs index 6ad9045cfe..17f11b0a0f 100644 --- a/opentelemetry-otlp/src/span.rs +++ b/opentelemetry-otlp/src/span.rs @@ -164,8 +164,11 @@ fn build_simple_with_exporter( provider_builder = provider_builder.with_config(config); } let provider = provider_builder.build(); - let tracer = - provider.versioned_tracer("opentelemetry-otlp", Some(env!("CARGO_PKG_VERSION")), None); + let tracer = provider.versioned_tracer( + "opentelemetry-otlp".into(), + Some(env!("CARGO_PKG_VERSION").into()), + None, + ); let _ = global::set_tracer_provider(provider); tracer } @@ -186,8 +189,11 @@ fn build_batch_with_exporter( provider_builder = provider_builder.with_config(config); } let provider = provider_builder.build(); - let tracer = - provider.versioned_tracer("opentelemetry-otlp", Some(env!("CARGO_PKG_VERSION")), None); + let tracer = provider.versioned_tracer( + "opentelemetry-otlp".into(), + Some(env!("CARGO_PKG_VERSION").into()), + None, + ); let _ = global::set_tracer_provider(provider); tracer } diff --git a/opentelemetry-prometheus/src/lib.rs b/opentelemetry-prometheus/src/lib.rs index 15a5c13604..4666013249 100644 --- a/opentelemetry-prometheus/src/lib.rs +++ b/opentelemetry-prometheus/src/lib.rs @@ -20,7 +20,7 @@ //! //! // set up a meter meter to create instruments //! let provider = MeterProvider::builder().with_reader(exporter).build(); -//! let meter = provider.meter("my-app"); +//! let meter = provider.meter("my-app".into()); //! //! // Use two instruments //! let counter = meter diff --git a/opentelemetry-prometheus/tests/integration_test.rs b/opentelemetry-prometheus/tests/integration_test.rs index 14be09da0f..4d0e48e23b 100644 --- a/opentelemetry-prometheus/tests/integration_test.rs +++ b/opentelemetry-prometheus/tests/integration_test.rs @@ -302,7 +302,7 @@ fn prometheus_exporter_integration() { .unwrap(), ) .build(); - let meter = provider.versioned_meter("testmeter", Some("v0.1.0"), None); + let meter = provider.versioned_meter("testmeter".into(), Some("v0.1.0".into()), None); (tc.record_metrics)(&cx, meter); let content = fs::read_to_string(Path::new("./tests/data").join(tc.expected_file)) @@ -354,7 +354,7 @@ fn multiple_scopes() { .build(); let foo_counter = provider - .versioned_meter("meterfoo", Some("v0.1.0"), None) + .versioned_meter("meterfoo".into(), Some("v0.1.0".into()), None) .u64_counter("foo") .with_unit(Unit::new("ms")) .with_description("meter foo counter") @@ -362,7 +362,7 @@ fn multiple_scopes() { foo_counter.add(&cx, 100, &[KeyValue::new("type", "foo")]); let bar_counter = provider - .versioned_meter("meterbar", Some("v0.1.0"), None) + .versioned_meter("meterbar".into(), Some("v0.1.0".into()), None) .u64_counter("bar") .with_unit(Unit::new("ms")) .with_description("meter bar counter") @@ -689,8 +689,8 @@ fn duplicate_metrics() { .with_reader(exporter) .build(); - let meter_a = provider.versioned_meter("ma", Some("v0.1.0"), None); - let meter_b = provider.versioned_meter("mb", Some("v0.1.0"), None); + let meter_a = provider.versioned_meter("ma".into(), Some("v0.1.0".into()), None); + let meter_b = provider.versioned_meter("mb".into(), Some("v0.1.0".into()), None); (tc.record_metrics)(&cx, meter_a, meter_b); diff --git a/opentelemetry-sdk/benches/metric.rs b/opentelemetry-sdk/benches/metric.rs index 1f102000ab..32e449b37a 100644 --- a/opentelemetry-sdk/benches/metric.rs +++ b/opentelemetry-sdk/benches/metric.rs @@ -61,7 +61,7 @@ fn bench_counter(view: Option>) -> (Context, SharedReader, Counter builder = builder.with_view(view); } let provider = builder.build(); - let cntr = provider.meter("test").u64_counter("hello").init(); + let cntr = provider.meter("test".into()).u64_counter("hello").init(); (cx, rdr, cntr) } @@ -150,7 +150,7 @@ fn benchmark_collect_histogram(b: &mut Bencher, n: usize) { let mtr = MeterProvider::builder() .with_reader(r.clone()) .build() - .meter("sdk/metric/bench/histogram"); + .meter("sdk/metric/bench/histogram".into()); for i in 0..n { let h = mtr.i64_histogram(format!("fake_data_{i}")).init(); diff --git a/opentelemetry-sdk/benches/trace.rs b/opentelemetry-sdk/benches/trace.rs index 4d75e7493c..6529a25a71 100644 --- a/opentelemetry-sdk/benches/trace.rs +++ b/opentelemetry-sdk/benches/trace.rs @@ -115,7 +115,7 @@ fn trace_benchmark_group(c: &mut Criterion, name: &str .with_config(sdktrace::config().with_sampler(sdktrace::Sampler::AlwaysOn)) .with_simple_exporter(VoidExporter) .build(); - let always_sample = provider.tracer("always-sample"); + let always_sample = provider.tracer("always-sample".into()); b.iter(|| f(&always_sample)); }); @@ -125,7 +125,7 @@ fn trace_benchmark_group(c: &mut Criterion, name: &str .with_config(sdktrace::config().with_sampler(sdktrace::Sampler::AlwaysOff)) .with_simple_exporter(VoidExporter) .build(); - let never_sample = provider.tracer("never-sample"); + let never_sample = provider.tracer("never-sample".into()); b.iter(|| f(&never_sample)); }); diff --git a/opentelemetry-sdk/src/export/trace/stdout.rs b/opentelemetry-sdk/src/export/trace/stdout.rs index 68bd0b172c..5d3dce64d0 100644 --- a/opentelemetry-sdk/src/export/trace/stdout.rs +++ b/opentelemetry-sdk/src/export/trace/stdout.rs @@ -99,8 +99,11 @@ where } let provider = provider_builder.build(); - let tracer = - provider.versioned_tracer("opentelemetry", Some(env!("CARGO_PKG_VERSION")), None); + let tracer = provider.versioned_tracer( + "opentelemetry".into(), + Some(env!("CARGO_PKG_VERSION").into()), + None, + ); let _ = global::set_tracer_provider(provider); tracer diff --git a/opentelemetry-sdk/src/metrics/meter_provider.rs b/opentelemetry-sdk/src/metrics/meter_provider.rs index 000f2e1c2b..e4fbc5fcbf 100644 --- a/opentelemetry-sdk/src/metrics/meter_provider.rs +++ b/opentelemetry-sdk/src/metrics/meter_provider.rs @@ -1,7 +1,10 @@ use core::fmt; -use std::sync::{ - atomic::{AtomicBool, Ordering}, - Arc, +use std::{ + borrow::Cow, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, }; use opentelemetry_api::{ @@ -73,9 +76,9 @@ impl MeterProvider { impl opentelemetry_api::metrics::MeterProvider for MeterProvider { fn versioned_meter( &self, - name: &'static str, - version: Option<&'static str>, - schema_url: Option<&'static str>, + name: Cow<'static, str>, + version: Option>, + schema_url: Option>, ) -> ApiMeter { let inst_provider: Arc = if !self.is_shutdown.load(Ordering::Relaxed) { diff --git a/opentelemetry-sdk/src/metrics/mod.rs b/opentelemetry-sdk/src/metrics/mod.rs index d765c834d3..1981354d79 100644 --- a/opentelemetry-sdk/src/metrics/mod.rs +++ b/opentelemetry-sdk/src/metrics/mod.rs @@ -24,7 +24,7 @@ //! let provider = MeterProvider::builder().with_resource(resource).build(); //! //! // Use the meter provider to create meter instances -//! let meter = provider.meter("my_app"); +//! let meter = provider.meter("my_app".into()); //! //! // Create instruments scoped to the meter //! let counter = meter diff --git a/opentelemetry-sdk/src/propagation/composite.rs b/opentelemetry-sdk/src/propagation/composite.rs index cddd6c934c..43689056a2 100644 --- a/opentelemetry-sdk/src/propagation/composite.rs +++ b/opentelemetry-sdk/src/propagation/composite.rs @@ -44,7 +44,7 @@ use std::collections::HashSet; /// /// // And a given span /// let example_span = sdktrace::TracerProvider::default() -/// .tracer("example-component") +/// .tracer("example-component".into()) /// .start("span-name"); /// /// // with the current context, call inject to add the headers diff --git a/opentelemetry-sdk/src/trace/provider.rs b/opentelemetry-sdk/src/trace/provider.rs index ddd73b30b4..ca17fe88d8 100644 --- a/opentelemetry-sdk/src/trace/provider.rs +++ b/opentelemetry-sdk/src/trace/provider.rs @@ -122,22 +122,17 @@ impl opentelemetry_api::trace::TracerProvider for TracerProvider { /// Create a new versioned `Tracer` instance. fn versioned_tracer( &self, - name: impl Into>, - version: Option<&'static str>, - schema_url: Option<&'static str>, + name: Cow<'static, str>, + version: Option>, + schema_url: Option>, ) -> Self::Tracer { - let name = name.into(); // Use default value if name is invalid empty string let component_name = if name.is_empty() { Cow::Borrowed(DEFAULT_COMPONENT_NAME) } else { name }; - let instrumentation_lib = InstrumentationLibrary::new( - component_name, - version.map(Into::into), - schema_url.map(Into::into), - ); + let instrumentation_lib = InstrumentationLibrary::new(component_name, version, schema_url); Tracer::new(instrumentation_lib, Arc::downgrade(&self.inner)) } diff --git a/opentelemetry-sdk/src/trace/span.rs b/opentelemetry-sdk/src/trace/span.rs index c1cd0fbd25..b744d3992b 100644 --- a/opentelemetry-sdk/src/trace/span.rs +++ b/opentelemetry-sdk/src/trace/span.rs @@ -251,7 +251,7 @@ mod tests { fn init() -> (crate::trace::Tracer, SpanData) { let provider = crate::trace::TracerProvider::default(); let config = provider.config(); - let tracer = provider.tracer("opentelemetry"); + let tracer = provider.tracer("opentelemetry".into()); let data = SpanData { parent_span_id: SpanId::from_u64(0), span_kind: trace::SpanKind::Internal, @@ -500,7 +500,7 @@ mod tests { let provider_builder = crate::trace::TracerProvider::builder().with_simple_exporter(exporter); let provider = provider_builder.build(); - let tracer = provider.tracer("opentelemetry-test"); + let tracer = provider.tracer("opentelemetry-test".into()); let mut event1 = Event::with_name("test event"); for i in 0..(DEFAULT_MAX_ATTRIBUTES_PER_EVENT * 2) { @@ -535,7 +535,7 @@ mod tests { let provider_builder = crate::trace::TracerProvider::builder().with_simple_exporter(exporter); let provider = provider_builder.build(); - let tracer = provider.tracer("opentelemetry-test"); + let tracer = provider.tracer("opentelemetry-test".into()); let mut link = Link::new( SpanContext::new( @@ -569,7 +569,7 @@ mod tests { let provider = crate::trace::TracerProvider::builder() .with_simple_exporter(NoopSpanExporter::new()) .build(); - let tracer = provider.tracer("test"); + let tracer = provider.tracer("test".into()); let mut span = tracer.start("test_span"); span.add_event("test_event", vec![]); diff --git a/opentelemetry-sdk/src/trace/tracer.rs b/opentelemetry-sdk/src/trace/tracer.rs index 2e4dc68198..2eef59e04e 100644 --- a/opentelemetry-sdk/src/trace/tracer.rs +++ b/opentelemetry-sdk/src/trace/tracer.rs @@ -322,7 +322,7 @@ mod tests { let tracer_provider = crate::trace::TracerProvider::builder() .with_config(config) .build(); - let tracer = tracer_provider.tracer("test"); + let tracer = tracer_provider.tracer("test".into()); let trace_state = TraceState::from_key_value(vec![("foo", "bar")]).unwrap(); let parent_context = Context::new().with_span(TestSpan(SpanContext::new( @@ -349,7 +349,7 @@ mod tests { .build(); let context = Context::current_with_span(TestSpan(SpanContext::empty_context())); - let tracer = tracer_provider.tracer("test"); + let tracer = tracer_provider.tracer("test".into()); let span = tracer.start_with_context("must_not_be_sampled", &context); assert!(!span.span_context().is_sampled()); @@ -362,7 +362,7 @@ mod tests { let tracer_provider = crate::trace::TracerProvider::builder() .with_config(config) .build(); - let tracer = tracer_provider.tracer("test"); + let tracer = tracer_provider.tracer("test".into()); let _attached = Context::current_with_span(TestSpan(SpanContext::empty_context())).attach(); let span = tracer.span_builder("must_not_be_sampled").start(&tracer); diff --git a/opentelemetry-zipkin/src/exporter/mod.rs b/opentelemetry-zipkin/src/exporter/mod.rs index 02e6f60503..ce650f1ea3 100644 --- a/opentelemetry-zipkin/src/exporter/mod.rs +++ b/opentelemetry-zipkin/src/exporter/mod.rs @@ -176,8 +176,8 @@ impl ZipkinPipelineBuilder { provider_builder = provider_builder.with_config(config); let provider = provider_builder.build(); let tracer = provider.versioned_tracer( - "opentelemetry-zipkin", - Some(env!("CARGO_PKG_VERSION")), + "opentelemetry-zipkin".into(), + Some(env!("CARGO_PKG_VERSION").into()), None, ); let _ = global::set_tracer_provider(provider); @@ -197,8 +197,8 @@ impl ZipkinPipelineBuilder { provider_builder = provider_builder.with_config(config); let provider = provider_builder.build(); let tracer = provider.versioned_tracer( - "opentelemetry-zipkin", - Some(env!("CARGO_PKG_VERSION")), + "opentelemetry-zipkin".into(), + Some(env!("CARGO_PKG_VERSION").into()), None, ); let _ = global::set_tracer_provider(provider);