Skip to content

Commit

Permalink
update(api,subscriber)!: upgrade tonic to 0.12 (#571)
Browse files Browse the repository at this point in the history
Update all dependencies on `tonic` and `tonic-build` to v0.12, along
with the related `prost`, `prost-types` and `prost-build` crates to
v0.13.1.

BREAKING CHANGE:
This is a breaking change for users of `console-api` and
`console-subscriber`, as it changes the public `tonic`, `prost` and
`prost-types` dependency to a semver-incompatible version. This breaks
compatibility with `tonic` 0.11.x as well as `prost`/`prost-types`
0.12.x.

Co-authored-by: Hayden Stainsby <hds@caffeineconcepts.com>
  • Loading branch information
dnaka91 and hds authored Jul 12, 2024
1 parent b01631a commit 5f6faa2
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 177 deletions.
204 changes: 107 additions & 97 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions console-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ keywords = [
transport = ["tonic/transport"]

[dependencies]
tonic = { version = "0.11", default-features = false, features = [
tonic = { version = "0.12", default-features = false, features = [
"prost",
"codegen",
"transport",
] }
prost = "0.12"
prost-types = "0.12"
prost = "0.13.1"
prost-types = "0.13.1"
tracing-core = "0.1.17"
futures-core = "0.3"

[dev-dependencies]
tonic-build = { version = "0.11", default-features = false, features = [
tonic-build = { version = "0.12", default-features = false, features = [
"prost", "transport"
] }
# explicit dep so we can get the version with fixed whitespace.
prost-build = "0.12.0"
prost-build = "0.13.1"

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 0 additions & 2 deletions console-api/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ impl From<Id> for u64 {
}
}

impl Copy for Id {}

impl From<tracing_core::span::Id> for Id {
fn from(id: tracing_core::span::Id) -> Self {
Id { id: id.into_u64() }
Expand Down
1 change: 1 addition & 0 deletions console-api/src/generated/rs.tokio.console.async_ops.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
/// An `AsyncOp` state update.
///
/// This includes a list of any new async ops, and updates to the associated statistics
Expand Down
9 changes: 5 additions & 4 deletions console-api/src/generated/rs.tokio.console.common.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This file is @generated by prost-build.
/// Unique identifier for each task.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Id {
/// The unique identifier's concrete value.
#[prost(uint64, tag = "1")]
Expand All @@ -25,15 +26,15 @@ pub struct Location {
}
/// Unique identifier for metadata.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct MetaId {
/// The unique identifier's concrete value.
#[prost(uint64, tag = "1")]
pub id: u64,
}
/// Unique identifier for spans.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct SpanId {
/// The unique identifier's concrete value.
#[prost(uint64, tag = "1")]
Expand Down Expand Up @@ -273,7 +274,7 @@ pub mod metadata {
/// - tasks that have been spawned
/// - async operations on resources that are performed within the context of a task
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PollStats {
/// The total number of times this object has been polled.
#[prost(uint64, tag = "1")]
Expand Down
39 changes: 13 additions & 26 deletions console-api/src/generated/rs.tokio.console.instrument.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
// This file is @generated by prost-build.
/// InstrumentRequest requests the stream of updates
/// to observe the async runtime state over time.
///
/// TODO: In the future allow for the request to specify
/// only the data that the caller cares about (i.e. only
/// tasks but no resources)
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct InstrumentRequest {}
/// TaskDetailsRequest requests the stream of updates about
/// the specific task identified in the request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TaskDetailsRequest {
/// Identifies the task for which details were requested.
#[prost(message, optional, tag = "1")]
pub id: ::core::option::Option<super::common::Id>,
}
/// PauseRequest requests the stream of updates to pause.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PauseRequest {}
/// ResumeRequest requests the stream of updates to resume after a pause.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ResumeRequest {}
/// Update carries all information regarding tasks, resources, async operations
/// and resource operations in one message. There are a couple of reasons to combine all
Expand Down Expand Up @@ -56,11 +57,11 @@ pub struct Update {
}
/// `PauseResponse` is the value returned after a pause request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PauseResponse {}
/// `ResumeResponse` is the value returned after a resume request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ResumeResponse {}
/// Generated client implementations.
pub mod instrument_client {
Expand Down Expand Up @@ -314,19 +315,17 @@ pub mod instrument_server {
/// `InstrumentServer<T>` implements `Instrument` as a service.
#[derive(Debug)]
pub struct InstrumentServer<T: Instrument> {
inner: _Inner<T>,
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: Instrument> InstrumentServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
Expand Down Expand Up @@ -389,7 +388,6 @@ pub mod instrument_server {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/rs.tokio.console.instrument.Instrument/WatchUpdates" => {
#[allow(non_camel_case_types)]
Expand Down Expand Up @@ -421,7 +419,6 @@ pub mod instrument_server {
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = WatchUpdatesSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
Expand Down Expand Up @@ -468,7 +465,6 @@ pub mod instrument_server {
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = WatchTaskDetailsSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
Expand Down Expand Up @@ -512,7 +508,6 @@ pub mod instrument_server {
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = PauseSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
Expand Down Expand Up @@ -556,7 +551,6 @@ pub mod instrument_server {
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = ResumeSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
Expand All @@ -578,8 +572,11 @@ pub mod instrument_server {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.header("grpc-status", tonic::Code::Unimplemented as i32)
.header(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
)
.body(empty_body())
.unwrap(),
)
Expand All @@ -600,16 +597,6 @@ pub mod instrument_server {
}
}
}
impl<T: Instrument> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: Instrument> tonic::server::NamedService for InstrumentServer<T> {
const NAME: &'static str = "rs.tokio.console.instrument.Instrument";
}
Expand Down
1 change: 1 addition & 0 deletions console-api/src/generated/rs.tokio.console.resources.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
/// A resource state update.
///
/// Each `ResourceUpdate` contains any resource data that has changed since the last
Expand Down
3 changes: 2 additions & 1 deletion console-api/src/generated/rs.tokio.console.tasks.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
/// A task state update.
///
/// Each `TaskUpdate` contains any task data that has changed since the last
Expand Down Expand Up @@ -168,7 +169,7 @@ pub mod task {
}
/// Task performance statistics.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Stats {
/// Timestamp of when the task was spawned.
#[prost(message, optional, tag = "1")]
Expand Down
30 changes: 10 additions & 20 deletions console-api/src/generated/rs.tokio.console.trace.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.
/// Start watching trace events with the provided filter.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -26,7 +27,7 @@ pub mod trace_event {
}
/// `Enter` signals that a span was entered.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Enter {
/// `span_id` identifies the span that was entered.
#[prost(message, optional, tag = "1")]
Expand All @@ -40,7 +41,7 @@ pub mod trace_event {
}
/// `Exit` signals that a span was exited.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Exit {
/// `span_id` identifies the span that was exited.
#[prost(message, optional, tag = "1")]
Expand All @@ -54,7 +55,7 @@ pub mod trace_event {
}
/// `Close` signals that a span was closed.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Close {
/// `span_id` identifies the span that was closed.
#[prost(message, optional, tag = "1")]
Expand Down Expand Up @@ -223,19 +224,17 @@ pub mod trace_server {
/// Allows observers to stream trace events for a given `WatchRequest` filter.
#[derive(Debug)]
pub struct TraceServer<T: Trace> {
inner: _Inner<T>,
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: Trace> TraceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
Expand Down Expand Up @@ -298,7 +297,6 @@ pub mod trace_server {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/rs.tokio.console.trace.Trace/Watch" => {
#[allow(non_camel_case_types)]
Expand Down Expand Up @@ -330,7 +328,6 @@ pub mod trace_server {
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = WatchSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
Expand All @@ -352,8 +349,11 @@ pub mod trace_server {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.header("grpc-status", tonic::Code::Unimplemented as i32)
.header(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
)
.body(empty_body())
.unwrap(),
)
Expand All @@ -374,16 +374,6 @@ pub mod trace_server {
}
}
}
impl<T: Trace> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: Trace> tonic::server::NamedService for TraceServer<T> {
const NAME: &'static str = "rs.tokio.console.trace.Trace";
}
Expand Down
13 changes: 7 additions & 6 deletions console-subscriber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,32 @@ tokio = { version = "^1.21", features = ["sync", "time", "macros", "tracing"] }
tokio-stream = { version = "0.1", features = ["net"] }
thread_local = "1.1.3"
console-api = { version = "0.7.0", path = "../console-api", features = ["transport"] }
tonic = { version = "0.11", features = ["transport"] }
tonic = { version = "0.12", features = ["transport"] }
tracing-core = "0.1.24"
tracing = "0.1.26"
tracing-subscriber = { version = "0.3.17", default-features = false, features = ["fmt", "registry"] }
futures-task = { version = "0.3", default-features = false }
hdrhistogram = { version = "7.3.0", default-features = false, features = ["serialization"] }
parking_lot = { version = "0.12", optional = true }
humantime = "2.1.0"
prost = "0.12"
prost-types = "0.12.0"
prost = "0.13.1"
prost-types = "0.13.1"
hyper-util = { version = "0.1.6", features = ["tokio"] }

# Required for recording:
serde = { version = "1", features = ["derive"] }
serde_json = "1"
crossbeam-channel = "0.5"

# Only for the web feature:
tonic-web = { version = "0.11", optional = true }
tonic-web = { version = "0.12", optional = true }

[dev-dependencies]
tokio = { version = "^1.21", features = ["full", "rt-multi-thread"] }
tower = { version = "0.4", default-features = false }
futures = "0.3"
http = "0.2"
tower-http = { version = "0.4", features = ["cors"] }
http = "1.1"
tower-http = { version = "0.5", features = ["cors"] }

[package.metadata.docs.rs]
all-features = true
Expand Down
Loading

0 comments on commit 5f6faa2

Please sign in to comment.