Skip to content

Commit

Permalink
make Tracer::Clone cheaper open-telemetry#1092 (open-telemetry#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaun-cox authored Jun 6, 2023
1 parent 782f9db commit 18f6c01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions opentelemetry-sdk/src/trace/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ impl opentelemetry_api::trace::TracerProvider for TracerProvider {
} else {
name
};
let instrumentation_lib =
InstrumentationLibrary::new(component_name, version, schema_url, attributes);
let instrumentation_lib = Arc::new(InstrumentationLibrary::new(
component_name,
version,
schema_url,
attributes,
));

Tracer::new(instrumentation_lib, Arc::downgrade(&self.inner))
}
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-sdk/src/trace/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use opentelemetry_api::trace::{
};
use opentelemetry_api::{Context, Key, KeyValue, OrderMap, Value};
use std::fmt;
use std::sync::Weak;
use std::sync::{Arc, Weak};

/// `Tracer` implementation to create and manage spans
#[derive(Clone)]
pub struct Tracer {
instrumentation_lib: InstrumentationLibrary,
instrumentation_lib: Arc<InstrumentationLibrary>,
provider: Weak<TracerProviderInner>,
}

Expand All @@ -45,7 +45,7 @@ impl fmt::Debug for Tracer {
impl Tracer {
/// Create a new tracer (used internally by `TracerProvider`s).
pub(crate) fn new(
instrumentation_lib: InstrumentationLibrary,
instrumentation_lib: Arc<InstrumentationLibrary>,
provider: Weak<TracerProviderInner>,
) -> Self {
Tracer {
Expand Down

0 comments on commit 18f6c01

Please sign in to comment.