Skip to content

Commit

Permalink
Fixed incompatible install_simple with Tokio runtimes exporters
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed Sep 25, 2023
1 parent 88b8635 commit 1c1a460
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ rsb_derive = "0.5"
tokio = { version = "1" }
tokio-stream = "0.1"
futures = "0.3"
futures-util = "0.3"
async-trait = "0.1"


[dev-dependencies]
tokio = { version = "1", features = ["full"] }
tokio = { version = "1.29", features = ["full"] }
opentelemetry = { version = "0.20", features = ["rt-tokio"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter","registry"] }
Expand Down
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ impl GcpCloudTraceExporterBuilder {
) -> Result<opentelemetry::sdk::trace::Tracer, opentelemetry::trace::TraceError> {
let exporter = GcpCloudTraceExporter::new(&self.google_project_id).await?;

let mut provider_builder =
opentelemetry::sdk::trace::TracerProvider::builder().with_simple_exporter(exporter);
let mut provider_builder = opentelemetry::sdk::trace::TracerProvider::builder()
.with_batch_exporter(exporter, opentelemetry::runtime::Tokio);
provider_builder = if let Some(config) = self.trace_config {
provider_builder.with_config(config)
} else {
provider_builder
provider_builder.with_config(
opentelemetry::sdk::trace::config()
.with_sampler(opentelemetry::sdk::trace::Sampler::AlwaysOn),
)
};
let provider = provider_builder.build();
let tracer = provider.versioned_tracer(
Expand Down
2 changes: 1 addition & 1 deletion src/span_exporter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::errors::*;
use crate::google_trace_exporter_client::GcpCloudTraceExporterClient;
use crate::TraceExportResult;
use futures_util::future::{BoxFuture, TryFutureExt};
use futures::future::{BoxFuture, TryFutureExt};
use gcloud_sdk::GoogleEnvironment;
use opentelemetry::sdk::export::trace::{ExportResult, SpanData, SpanExporter};
use std::fmt::Formatter;
Expand Down

0 comments on commit 1c1a460

Please sign in to comment.