Skip to content

Commit ce423c7

Browse files
authored
Merge branch 'main' into separate-client-and-server-context
2 parents abbd2fc + a21b609 commit ce423c7

File tree

9 files changed

+49
-45
lines changed

9 files changed

+49
-45
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- unix: "--features unix"
4343
serde-transport: ""
4444
steps:
45-
- uses: actions/checkout@v4
45+
- uses: actions/checkout@v6
4646
- uses: dtolnay/rust-toolchain@stable
4747
- run: >
4848
cargo test --manifest-path tarpc/Cargo.toml
@@ -56,7 +56,7 @@ jobs:
5656
outputs:
5757
examples: ${{ steps.matrix.outputs.examples }}
5858
steps:
59-
- uses: actions/checkout@v4
59+
- uses: actions/checkout@v6
6060
- uses: dtolnay/rust-toolchain@stable
6161
- id: matrix
6262
run: |
@@ -79,7 +79,7 @@ jobs:
7979
matrix:
8080
example: ${{ fromJSON(needs.list-examples.outputs.examples) }}
8181
steps:
82-
- uses: actions/checkout@v4
82+
- uses: actions/checkout@v6
8383
- uses: dtolnay/rust-toolchain@stable
8484
- run: |
8585
cargo run --example "${{ matrix.example }}"
@@ -88,7 +88,7 @@ jobs:
8888
name: Rustfmt
8989
runs-on: ubuntu-latest
9090
steps:
91-
- uses: actions/checkout@v4
91+
- uses: actions/checkout@v6
9292
- uses: dtolnay/rust-toolchain@stable
9393
with:
9494
components: rustfmt
@@ -98,7 +98,7 @@ jobs:
9898
name: Clippy
9999
runs-on: ubuntu-latest
100100
steps:
101-
- uses: actions/checkout@v4
101+
- uses: actions/checkout@v6
102102
- uses: dtolnay/rust-toolchain@stable
103103
with:
104104
components: clippy

.github/workflows/pr_review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
clippy:
55
runs-on: ubuntu-latest
66
steps:
7-
- uses: actions/checkout@v4
7+
- uses: actions/checkout@v6
88
- uses: dtolnay/rust-toolchain@stable
99
with:
1010
components: clippy

example-service/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ description = "An example server built on tarpc."
1515

1616
[dependencies]
1717
anyhow = "1.0"
18-
clap = { version = "4.4.18", features = ["derive"] }
18+
clap = { version = "4.5", features = ["derive"] }
1919
log = "0.4"
2020
futures = "0.3"
21-
opentelemetry = { version = "0.30.0" }
22-
opentelemetry-otlp = { version = "0.30.0", features = ["grpc-tonic"] }
23-
rand = "0.8"
21+
opentelemetry = { version = "0.31" }
22+
opentelemetry-otlp = { version = "0.31", features = ["grpc-tonic"] }
23+
rand = "0.9"
2424
tarpc = { version = "0.37", path = "../tarpc", features = ["full"] }
2525
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread"] }
2626
tracing = { version = "0.1" }
27-
tracing-opentelemetry = "0.31.0"
27+
tracing-opentelemetry = "0.32"
2828
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
29-
opentelemetry_sdk = { version = "0.30.0", features = ["rt-tokio"] }
30-
opentelemetry-semantic-conventions = "0.30.0"
29+
opentelemetry_sdk = { version = "0.31", features = ["rt-tokio"] }
30+
opentelemetry-semantic-conventions = "0.31"
3131

3232
[lib]
3333
name = "service"

example-service/src/server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use clap::Parser;
88
use futures::{future, prelude::*};
99
use rand::{
10-
distributions::{Distribution, Uniform},
11-
thread_rng,
10+
distr::{Distribution, Uniform},
11+
rng,
1212
};
1313
use service::{World, init_tracing};
1414
use std::{
@@ -34,7 +34,7 @@ struct HelloServer(SocketAddr);
3434
impl World for HelloServer {
3535
async fn hello(self, _: &mut context::ServerContext, name: String) -> String {
3636
let sleep_time =
37-
Duration::from_millis(Uniform::new_inclusive(1, 10).sample(&mut thread_rng()));
37+
Duration::from_millis(Uniform::new_inclusive(1, 10).unwrap().sample(&mut rng()));
3838
time::sleep(sleep_time).await;
3939
format!("Hello, {name}! You are connected from {}", self.0)
4040
}

plugins/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ syn = { version = "2.0", features = ["full", "extra-traits"] }
2828
proc-macro = true
2929

3030
[dev-dependencies]
31-
assert-type-eq = "0.1.0"
31+
assert-type-eq = "0.1"
3232
futures = "0.3"
3333
futures-util = "0.3.31"
3434
serde = { version = "1.0", features = ["derive"] }

tarpc/Cargo.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,42 @@ travis-ci = { repository = "google/tarpc" }
4444
anyhow = "1.0"
4545
fnv = "1.0"
4646
futures = "0.3"
47-
humantime = "2.0"
48-
pin-project = "1.0"
49-
rand = "0.8"
47+
humantime = "2.3"
48+
pin-project = "1.1"
49+
rand = "0.9"
5050
serde = { optional = true, version = "1.0", features = ["derive"] }
51-
static_assertions = "1.1.0"
51+
static_assertions = "1.1"
5252
tarpc-plugins = { path = "../plugins", version = "0.14" }
5353
thiserror = "2.0"
5454
tokio = { version = "1", features = ["time"] }
55-
tokio-util = { version = "0.7.3", features = ["time"] }
55+
tokio-util = { version = "0.7", features = ["time"] }
5656
tokio-serde = { optional = true, version = "0.9" }
5757
tracing = { version = "0.1", default-features = false, features = [
5858
"attributes",
5959
"log",
6060
] }
61-
tracing-opentelemetry = { version = "0.31.0", default-features = false }
62-
opentelemetry = { version = "0.30.0", default-features = false }
63-
opentelemetry-semantic-conventions = "0.30.0"
61+
tracing-opentelemetry = { version = "0.32", default-features = false }
62+
opentelemetry = { version = "0.31", default-features = false }
63+
opentelemetry-semantic-conventions = "0.31"
6464

6565
[dev-dependencies]
66-
assert_matches = "1.4"
66+
assert_matches = "1.5"
6767
bincode = { version = "2.0", features = ["serde"] }
6868
bytes = { version = "1", features = ["serde"] }
69-
flate2 = "1.0"
69+
flate2 = "1.1"
7070
futures-test = "0.3"
71-
opentelemetry = { version = "0.30.0", default-features = false }
72-
opentelemetry-otlp = { version = "0.30.0", features = ["grpc-tonic"] }
73-
opentelemetry_sdk = { version = "0.30.0", features = ["rt-tokio"] }
74-
pin-utils = "0.1.0"
71+
opentelemetry = { version = "0.31", default-features = false }
72+
opentelemetry-otlp = { version = "0.31", features = ["grpc-tonic"] }
73+
opentelemetry_sdk = { version = "0.31", features = ["rt-tokio"] }
74+
pin-utils = "0.1"
7575
serde_bytes = "0.11"
7676
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
7777
tokio = { version = "1", features = ["full", "test-util", "tracing"] }
78-
console-subscriber = "0.4"
78+
console-subscriber = "0.5"
7979
tokio-serde = { version = "0.9", features = ["json", "bincode"] }
8080
trybuild = "1.0"
8181
tokio-rustls = "0.26"
82-
rustls-pemfile = "2.0"
82+
rustls-pemfile = "2.2"
8383

8484
[package.metadata.docs.rs]
8585
all-features = true

tarpc/src/context.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ pub(crate) trait SpanExt {
215215

216216
impl SpanExt for tracing::Span {
217217
fn set_context(&self, context: &SharedContext) {
218-
self.set_parent(
218+
// Explicitly ignore the returned result because it either means that the span has
219+
// already started, or the Otel layer is not present, so we don't mind if the result
220+
// is an error we silently ignore.
221+
let _ = self.set_parent(
219222
opentelemetry::Context::new()
220223
.with_remote_span_context(opentelemetry::trace::SpanContext::new(
221224
opentelemetry::trace::TraceId::from(context.trace_context.trace_id),

tarpc/src/trace.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@ pub struct SpanId(u64);
6666
/// dependencies. On the other hand, if an upstream process has chosen to sample this trace, then
6767
/// the downstream samplers are expected to respect that decision and also sample the trace.
6868
/// Otherwise, the full trace would not be able to be reconstructed reliably.
69-
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
69+
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Default)]
7070
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
7171
#[repr(u8)]
7272
pub enum SamplingDecision {
7373
/// The associated span was sampled by its creating process. Child spans must also be sampled.
7474
Sampled,
7575
/// The associated span was not sampled by its creating process.
76+
#[default]
7677
Unsampled,
7778
}
7879

@@ -81,7 +82,7 @@ impl Context {
8182
pub(crate) fn new_child(&self) -> Self {
8283
Self {
8384
trace_id: self.trace_id,
84-
span_id: SpanId::random(&mut rand::thread_rng()),
85+
span_id: SpanId::random(&mut rand::rng()),
8586
sampling_decision: self.sampling_decision,
8687
}
8788
}
@@ -91,7 +92,7 @@ impl TraceId {
9192
/// Returns a random trace ID that can be assumed to be globally unique if `rng` generates
9293
/// actually-random numbers.
9394
pub fn random<R: Rng>(rng: &mut R) -> Self {
94-
TraceId(rng.r#gen::<NonZeroU128>().get())
95+
TraceId(rng.random::<NonZeroU128>().get())
9596
}
9697

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

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

206-
impl Default for SamplingDecision {
207-
fn default() -> Self {
208-
Self::Unsampled
209-
}
210-
}
211-
212207
/// Returned when a [`Context`] cannot be constructed from a [`Span`](tracing::Span).
213208
#[derive(Debug)]
214209
pub struct NoActiveSpan;

tarpc/tests/compile_fail/serde1/opt_out_serde.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ error[E0277]: the trait bound `FooRequest: serde::Serialize` is not satisfied
22
--> tests/compile_fail/serde1/opt_out_serde.rs:12:40
33
|
44
12 | tarpc::serde::Serialize::serialize(&x, f);
5-
| ---------------------------------- ^^ the trait `Serialize` is not implemented for `FooRequest`
5+
| ---------------------------------- ^^ unsatisfied trait bound
66
| |
77
| required by a bound introduced by this call
88
|
9+
help: the trait `Serialize` is not implemented for `FooRequest`
10+
--> tests/compile_fail/serde1/opt_out_serde.rs:5:1
11+
|
12+
5 | #[tarpc::service(derive_serde = false)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
914
= note: for local types consider adding `#[derive(serde::Serialize)]` to your `FooRequest` type
1015
= note: for types from other crates check whether the crate offers a `serde` feature flag
1116
= help: the following other types implement trait `Serialize`:
@@ -18,3 +23,4 @@ error[E0277]: the trait bound `FooRequest: serde::Serialize` is not satisfied
1823
(T0, T1, T2, T3)
1924
(T0, T1, T2, T3, T4)
2025
and $N others
26+
= note: this error originates in the attribute macro `tarpc::service` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)