Skip to content

Commit

Permalink
Add warning about assigning the uninstaller to '_' (#372)
Browse files Browse the repository at this point in the history
It is common rust convention to use _ to signify an unused variable. Because we _are_ using this (until the end of the block) it is helpful to explain the intent.
  • Loading branch information
arlyon committed Dec 2, 2020
1 parent 89882c6 commit bd17c16
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -37,6 +37,9 @@ use opentelemetry::{exporter::trace::stdout, trace::Tracer};

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
// Create a new instrumentation pipeline
// Note: uninstalling the tracer happens when the _uninstall
// variable is dropped. Assigning it to _ will immediately
// drop it and uninstall the tracer
let (tracer, _uninstall) = stdout::new_pipeline().install();

tracer.in_span("doing_work", |cx| {
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-contrib/src/trace/exporter/datadog/mod.rs
Expand Up @@ -285,5 +285,6 @@ impl trace::SpanExporter for DatadogExporter {
}

/// Uninstalls the Datadog pipeline on drop
#[must_use]
#[derive(Debug)]
pub struct Uninstall(global::TracerProviderGuard);
1 change: 1 addition & 0 deletions opentelemetry-jaeger/src/lib.rs
Expand Up @@ -226,6 +226,7 @@ pub fn new_pipeline() -> PipelineBuilder {
}

/// Guard that uninstalls the Jaeger trace pipeline when dropped
#[must_use]
#[derive(Debug)]
pub struct Uninstall(global::TracerProviderGuard);

Expand Down
1 change: 1 addition & 0 deletions opentelemetry-otlp/src/lib.rs
Expand Up @@ -232,6 +232,7 @@ impl OtlpPipelineBuilder {
}

/// Uninstalls the OTLP pipeline on drop
#[must_use]
#[derive(Debug)]
pub struct Uninstall(global::TracerProviderGuard);

Expand Down
1 change: 1 addition & 0 deletions opentelemetry-zipkin/src/lib.rs
Expand Up @@ -324,6 +324,7 @@ impl trace::SpanExporter for Exporter {
}

/// Uninstalls the Zipkin pipeline on drop.
#[must_use]
#[derive(Debug)]
pub struct Uninstall(global::TracerProviderGuard);

Expand Down
3 changes: 2 additions & 1 deletion opentelemetry/src/exporter/trace/stdout.rs
Expand Up @@ -147,7 +147,8 @@ where
}
}

/// Uninstalls the stdout pipeline on dropping.
/// Uninstalls the stdout pipeline on drop.
#[must_use]
#[derive(Debug)]
pub struct Uninstall(global::TracerProviderGuard);

Expand Down

0 comments on commit bd17c16

Please sign in to comment.