From 7cb6a15acdd449853dd728cd6a2fd194b0e00d01 Mon Sep 17 00:00:00 2001 From: "Aode (lion)" Date: Sun, 19 Sep 2021 14:36:53 -0500 Subject: [PATCH] Wire up cross-application propagation --- Cargo.lock | 2 ++ Cargo.toml | 8 +++++++- src/main.rs | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd3775e..f5c1b78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2043,8 +2043,10 @@ version = "0.4.0-beta.12" source = "git+https://github.com/asonix/tracing-actix-web?branch=asonix/tracing-error-work-around#51e7911af7d1dd6a9c8265fa19b94224ddff56e2" dependencies = [ "actix-web", + "opentelemetry", "tracing", "tracing-futures", + "tracing-opentelemetry", "uuid", ] diff --git a/Cargo.toml b/Cargo.toml index 872c05c..b29b27b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,10 +35,16 @@ time = { version = "0.3.0", features = ["serde"] } tokio = { version = "1", default-features = false, features = ["fs", "io-util", "process", "sync"] } tokio-util = { version = "0.6", default-features = false, features = ["codec"] } tracing = "0.1.15" -tracing-actix-web = { version = "0.4.0-beta.8", git = "https://github.com/asonix/tracing-actix-web", branch = "asonix/tracing-error-work-around" } tracing-error = "0.1.2" tracing-futures = "0.2.4" tracing-log = "0.1.2" tracing-opentelemetry = "0.15" tracing-subscriber = { version = "0.2.5", features = ["fmt", "tracing-log"] } url = "2.2" + +[dependencies.tracing-actix-web] +version = "0.4.0-beta.8" +git = "https://github.com/asonix/tracing-actix-web" +branch = "asonix/tracing-error-work-around" +default-features = false +features = ["emit_event_on_error", "opentelemetry_0_16"] diff --git a/src/main.rs b/src/main.rs index 96ab3c8..e6cf7ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use futures_util::{ Stream, }; use once_cell::sync::Lazy; -use opentelemetry::{sdk::Resource, KeyValue}; +use opentelemetry::{sdk::{Resource, propagation::TraceContextPropagator}, KeyValue}; use opentelemetry_otlp::WithExportConfig; use std::{ collections::HashSet, @@ -794,6 +794,8 @@ async fn filename_by_alias( async fn main() -> Result<(), anyhow::Error> { LogTracer::init()?; + opentelemetry::global::set_text_map_propagator(TraceContextPropagator::new()); + let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")); let format_layer = tracing_subscriber::fmt::layer() .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)