diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8a57939..34c1018 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,6 +17,9 @@ jobs: - name: Run the default tests package: ractor # flags: + - name: Test ractor without span propogation + package: ractor + flags: --no-default-features -F tokio_runtime,async-trait - name: Test ractor with the `cluster` feature package: ractor flags: -F cluster diff --git a/ractor/Cargo.toml b/ractor/Cargo.toml index 4d4fb24..694f3b2 100644 --- a/ractor/Cargo.toml +++ b/ractor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ractor" -version = "0.13.4" +version = "0.13.5" authors = ["Sean Lawlor", "Evan Au", "Dillon George"] description = "A actor framework for Rust" documentation = "https://docs.rs/ractor" @@ -19,10 +19,11 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] } [features] ### Other features cluster = [] +message_span_propogation = [] tokio_runtime = ["tokio/time", "tokio/rt", "tokio/macros", "tokio/tracing"] blanket_serde = ["serde", "pot", "cluster"] -default = ["tokio_runtime", "async-trait"] +default = ["tokio_runtime", "async-trait", "message_span_propogation"] [dependencies] ## Required dependencies diff --git a/ractor/src/message.rs b/ractor/src/message.rs index d0a4479..eb59f81 100644 --- a/ractor/src/message.rs +++ b/ractor/src/message.rs @@ -134,6 +134,16 @@ pub trait Message: Any + Send + Sized + 'static { /// Convert this message to a [BoxedMessage] #[cfg(feature = "cluster")] fn box_message(self, pid: &ActorId) -> Result { + let span = { + #[cfg(feature = "message_span_propogation")] + { + Some(tracing::Span::current()) + } + #[cfg(not(feature = "message_span_propogation"))] + { + None + } + }; if Self::serializable() && !pid.is_local() { // it's a message to a remote actor, serialize it and send it over the wire! Ok(BoxedMessage { @@ -145,7 +155,7 @@ pub trait Message: Any + Send + Sized + 'static { Ok(BoxedMessage { msg: Some(Box::new(self)), serialized_msg: None, - span: Some(tracing::Span::current()), + span, }) } else { Err(BoxedDowncastErr) @@ -156,9 +166,19 @@ pub trait Message: Any + Send + Sized + 'static { #[cfg(not(feature = "cluster"))] #[allow(unused_variables)] fn box_message(self, pid: &ActorId) -> Result { + let span = { + #[cfg(feature = "message_span_propogation")] + { + Some(tracing::Span::current()) + } + #[cfg(not(feature = "message_span_propogation"))] + { + None + } + }; Ok(BoxedMessage { msg: Some(Box::new(self)), - span: Some(tracing::Span::current()), + span, }) } diff --git a/ractor_cluster/Cargo.toml b/ractor_cluster/Cargo.toml index 18e2438..716cc1d 100644 --- a/ractor_cluster/Cargo.toml +++ b/ractor_cluster/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ractor_cluster" -version = "0.13.4" +version = "0.13.5" authors = ["Sean Lawlor", "Evan Au", "Dillon George"] description = "Distributed cluster environment of Ractor actors" documentation = "https://docs.rs/ractor" diff --git a/ractor_cluster_derive/Cargo.toml b/ractor_cluster_derive/Cargo.toml index f996586..5d18794 100644 --- a/ractor_cluster_derive/Cargo.toml +++ b/ractor_cluster_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ractor_cluster_derive" -version = "0.13.4" +version = "0.13.5" authors = ["Sean Lawlor "] description = "Derives for ractor_cluster" license = "MIT"