Skip to content

Commit

Permalink
fix(exmaples): actix web should use TokioCurrentThread as runtime (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyCpp committed Feb 14, 2022
1 parent b695ba1 commit ed71d80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/actix-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish = false

[dependencies]
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio"] }
opentelemetry-jaeger = { path = "../../opentelemetry-jaeger", features = ["reqwest_collector_client", "rt-tokio"] }
opentelemetry-jaeger = { path = "../../opentelemetry-jaeger", features = ["reqwest_collector_client", "rt-tokio-current-thread"] }
thrift = "0.13"
actix-web = "4.0.0-beta.4"
actix-service = "2.0.0-beta.5"
Expand Down
10 changes: 8 additions & 2 deletions examples/actix-http/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use actix_service::Service;
use actix_web::middleware::Logger;
use actix_web::{web, App, HttpServer};
use opentelemetry::global::shutdown_tracer_provider;
use opentelemetry::trace::TraceError;
use opentelemetry::{global, sdk::trace as sdktrace};
use opentelemetry::{
Expand All @@ -12,7 +13,7 @@ fn init_tracer() -> Result<sdktrace::Tracer, TraceError> {
opentelemetry_jaeger::new_pipeline()
.with_collector_endpoint("http://127.0.0.1:14268/api/traces")
.with_service_name("trace-http-demo")
.install_batch(opentelemetry::runtime::Tokio)
.install_batch(opentelemetry::runtime::TokioCurrentThread)
}

async fn index() -> &'static str {
Expand Down Expand Up @@ -45,5 +46,10 @@ async fn main() -> std::io::Result<()> {
.bind("127.0.0.1:8088")
.unwrap()
.run()
.await
.await?;

// wait until all pending spans get exported.
shutdown_tracer_provider();

Ok(())
}

0 comments on commit ed71d80

Please sign in to comment.