Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make Tracer::Clone cheaper (another 10% improvement to start-end-span/never-sample) #1093

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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