Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- unix: "--features unix"
serde-transport: ""
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- run: >
cargo test --manifest-path tarpc/Cargo.toml
Expand All @@ -56,7 +56,7 @@ jobs:
outputs:
examples: ${{ steps.matrix.outputs.examples }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- id: matrix
run: |
Expand All @@ -79,7 +79,7 @@ jobs:
matrix:
example: ${{ fromJSON(needs.list-examples.outputs.examples) }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- run: |
cargo run --example "${{ matrix.example }}"
Expand All @@ -88,7 +88,7 @@ jobs:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
Expand All @@ -98,7 +98,7 @@ jobs:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
Expand Down
14 changes: 7 additions & 7 deletions example-service/Cargo.toml
Comment thread
tikue marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ description = "An example server built on tarpc."

[dependencies]
anyhow = "1.0"
clap = { version = "4.4.18", features = ["derive"] }
clap = { version = "4.5", features = ["derive"] }
log = "0.4"
futures = "0.3"
opentelemetry = { version = "0.30.0" }
opentelemetry-otlp = { version = "0.30.0", features = ["grpc-tonic"] }
rand = "0.8"
opentelemetry = { version = "0.31" }
opentelemetry-otlp = { version = "0.31", features = ["grpc-tonic"] }
rand = "0.9"
tarpc = { version = "0.37", path = "../tarpc", features = ["full"] }
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread"] }
tracing = { version = "0.1" }
tracing-opentelemetry = "0.31.0"
tracing-opentelemetry = "0.32"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
opentelemetry_sdk = { version = "0.30.0", features = ["rt-tokio"] }
opentelemetry-semantic-conventions = "0.30.0"
opentelemetry_sdk = { version = "0.31", features = ["rt-tokio"] }
opentelemetry-semantic-conventions = "0.31"

[lib]
name = "service"
Expand Down
6 changes: 3 additions & 3 deletions example-service/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use clap::Parser;
use futures::{future, prelude::*};
use rand::{
distributions::{Distribution, Uniform},
thread_rng,
distr::{Distribution, Uniform},
rng,
};
use service::{World, init_tracing};
use std::{
Expand Down Expand Up @@ -37,7 +37,7 @@ struct HelloServer(SocketAddr);
impl World for HelloServer {
async fn hello(self, _: context::Context, name: String) -> String {
let sleep_time =
Duration::from_millis(Uniform::new_inclusive(1, 10).sample(&mut thread_rng()));
Duration::from_millis(Uniform::new_inclusive(1, 10).unwrap().sample(&mut rng()));
Comment thread
tikue marked this conversation as resolved.
time::sleep(sleep_time).await;
format!("Hello, {name}! You are connected from {}", self.0)
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ syn = { version = "2.0", features = ["full", "extra-traits"] }
proc-macro = true

[dev-dependencies]
assert-type-eq = "0.1.0"
assert-type-eq = "0.1"
futures = "0.3"
serde = { version = "1.0", features = ["derive"] }
tarpc = { path = "../tarpc", features = ["serde1"] }
32 changes: 16 additions & 16 deletions tarpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,42 @@ travis-ci = { repository = "google/tarpc" }
anyhow = "1.0"
fnv = "1.0"
futures = "0.3"
humantime = "2.0"
pin-project = "1.0"
rand = "0.8"
humantime = "2.3"
pin-project = "1.1"
rand = "0.9"
serde = { optional = true, version = "1.0", features = ["derive"] }
static_assertions = "1.1.0"
static_assertions = "1.1"
tarpc-plugins = { path = "../plugins", version = "0.14" }
thiserror = "2.0"
tokio = { version = "1", features = ["time"] }
tokio-util = { version = "0.7.3", features = ["time"] }
tokio-util = { version = "0.7", features = ["time"] }
tokio-serde = { optional = true, version = "0.9" }
tracing = { version = "0.1", default-features = false, features = [
"attributes",
"log",
] }
tracing-opentelemetry = { version = "0.31.0", default-features = false }
opentelemetry = { version = "0.30.0", default-features = false }
opentelemetry-semantic-conventions = "0.30.0"
tracing-opentelemetry = { version = "0.32", default-features = false }
opentelemetry = { version = "0.31", default-features = false }
opentelemetry-semantic-conventions = "0.31"

[dev-dependencies]
assert_matches = "1.4"
assert_matches = "1.5"
bincode = { version = "2.0", features = ["serde"] }
bytes = { version = "1", features = ["serde"] }
flate2 = "1.0"
flate2 = "1.1"
futures-test = "0.3"
opentelemetry = { version = "0.30.0", default-features = false }
opentelemetry-otlp = { version = "0.30.0", features = ["grpc-tonic"] }
opentelemetry_sdk = { version = "0.30.0", features = ["rt-tokio"] }
pin-utils = "0.1.0"
opentelemetry = { version = "0.31", default-features = false }
opentelemetry-otlp = { version = "0.31", features = ["grpc-tonic"] }
opentelemetry_sdk = { version = "0.31", features = ["rt-tokio"] }
pin-utils = "0.1"
serde_bytes = "0.11"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tokio = { version = "1", features = ["full", "test-util", "tracing"] }
console-subscriber = "0.4"
console-subscriber = "0.5"
tokio-serde = { version = "0.9", features = ["json", "bincode"] }
trybuild = "1.0"
tokio-rustls = "0.26"
rustls-pemfile = "2.0"
rustls-pemfile = "2.2"

[package.metadata.docs.rs]
all-features = true
Expand Down
5 changes: 4 additions & 1 deletion tarpc/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ pub(crate) trait SpanExt {

impl SpanExt for tracing::Span {
fn set_context(&self, context: &Context) {
self.set_parent(
// Explicitly ignore the returned result because it either means that the span has
// already started, or the Otel layer is not present, so we don't mind if the result
// is an error we silently ignore.
let _ = self.set_parent(
Comment thread
tikue marked this conversation as resolved.
opentelemetry::Context::new()
.with_remote_span_context(opentelemetry::trace::SpanContext::new(
opentelemetry::trace::TraceId::from(context.trace_context.trace_id),
Expand Down
15 changes: 5 additions & 10 deletions tarpc/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ pub struct SpanId(u64);
/// dependencies. On the other hand, if an upstream process has chosen to sample this trace, then
/// the downstream samplers are expected to respect that decision and also sample the trace.
/// Otherwise, the full trace would not be able to be reconstructed reliably.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Default)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[repr(u8)]
pub enum SamplingDecision {
/// The associated span was sampled by its creating process. Child spans must also be sampled.
Sampled,
/// The associated span was not sampled by its creating process.
#[default]
Unsampled,
}

Expand All @@ -81,7 +82,7 @@ impl Context {
pub(crate) fn new_child(&self) -> Self {
Self {
trace_id: self.trace_id,
span_id: SpanId::random(&mut rand::thread_rng()),
span_id: SpanId::random(&mut rand::rng()),
sampling_decision: self.sampling_decision,
}
}
Expand All @@ -91,7 +92,7 @@ impl TraceId {
/// Returns a random trace ID that can be assumed to be globally unique if `rng` generates
/// actually-random numbers.
pub fn random<R: Rng>(rng: &mut R) -> Self {
TraceId(rng.r#gen::<NonZeroU128>().get())
TraceId(rng.random::<NonZeroU128>().get())
Comment thread
tikue marked this conversation as resolved.
}

/// Returns true iff the trace ID is 0.
Expand All @@ -103,7 +104,7 @@ impl TraceId {
impl SpanId {
/// Returns a random span ID that can be assumed to be unique within a single trace.
pub fn random<R: Rng>(rng: &mut R) -> Self {
SpanId(rng.r#gen::<NonZeroU64>().get())
SpanId(rng.random::<NonZeroU64>().get())
}

/// Returns true iff the span ID is 0.
Expand Down Expand Up @@ -203,12 +204,6 @@ impl From<&opentelemetry::trace::SpanContext> for SamplingDecision {
}
}

impl Default for SamplingDecision {
fn default() -> Self {
Self::Unsampled
}
}

/// Returned when a [`Context`] cannot be constructed from a [`Span`](tracing::Span).
#[derive(Debug)]
pub struct NoActiveSpan;
Expand Down
8 changes: 7 additions & 1 deletion tarpc/tests/compile_fail/serde1/opt_out_serde.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ error[E0277]: the trait bound `FooRequest: serde::Serialize` is not satisfied
--> tests/compile_fail/serde1/opt_out_serde.rs:12:40
|
12 | tarpc::serde::Serialize::serialize(&x, f);
| ---------------------------------- ^^ the trait `Serialize` is not implemented for `FooRequest`
| ---------------------------------- ^^ unsatisfied trait bound
| |
| required by a bound introduced by this call
|
help: the trait `Serialize` is not implemented for `FooRequest`
--> tests/compile_fail/serde1/opt_out_serde.rs:5:1
|
5 | #[tarpc::service(derive_serde = false)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: for local types consider adding `#[derive(serde::Serialize)]` to your `FooRequest` type
= note: for types from other crates check whether the crate offers a `serde` feature flag
= help: the following other types implement trait `Serialize`:
Expand All @@ -18,3 +23,4 @@ error[E0277]: the trait bound `FooRequest: serde::Serialize` is not satisfied
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
and $N others
= note: this error originates in the attribute macro `tarpc::service` (in Nightly builds, run with -Z macro-backtrace for more info)