diff --git a/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.logs.v1.rs b/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.logs.v1.rs index f8ecf74237..84c9a5ca93 100644 --- a/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.logs.v1.rs +++ b/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.logs.v1.rs @@ -61,7 +61,13 @@ pub struct ExportLogsPartialSuccess { /// Generated client implementations. #[cfg(feature = "gen-tonic")] pub mod logs_service_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; use tonic::codegen::http::Uri; /// Service that can be used to push logs between one Application instrumented with @@ -160,8 +166,7 @@ pub mod logs_service_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -184,7 +189,13 @@ pub mod logs_service_client { /// Generated server implementations. #[cfg(feature = "gen-tonic")] pub mod logs_service_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with LogsServiceServer. #[async_trait] @@ -325,17 +336,19 @@ pub mod logs_service_server { } _ => { Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", tonic::Code::Unimplemented as i32) - .header( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ) - .body(empty_body()) - .unwrap(), - ) + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) }) } } diff --git a/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.metrics.v1.rs b/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.metrics.v1.rs index b5eb36e882..1f6951a60f 100644 --- a/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.metrics.v1.rs +++ b/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.metrics.v1.rs @@ -61,7 +61,13 @@ pub struct ExportMetricsPartialSuccess { /// Generated client implementations. #[cfg(feature = "gen-tonic")] pub mod metrics_service_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; use tonic::codegen::http::Uri; /// Service that can be used to push metrics between one Application @@ -160,8 +166,7 @@ pub mod metrics_service_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -184,7 +189,13 @@ pub mod metrics_service_client { /// Generated server implementations. #[cfg(feature = "gen-tonic")] pub mod metrics_service_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with MetricsServiceServer. #[async_trait] @@ -325,17 +336,19 @@ pub mod metrics_service_server { } _ => { Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", tonic::Code::Unimplemented as i32) - .header( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ) - .body(empty_body()) - .unwrap(), - ) + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) }) } } diff --git a/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.trace.v1.rs b/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.trace.v1.rs index ef73c77877..bf1238f82e 100644 --- a/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.trace.v1.rs +++ b/opentelemetry-proto/src/proto/tonic/opentelemetry.proto.collector.trace.v1.rs @@ -61,7 +61,13 @@ pub struct ExportTracePartialSuccess { /// Generated client implementations. #[cfg(feature = "gen-tonic")] pub mod trace_service_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; use tonic::codegen::http::Uri; /// Service that can be used to push spans between one Application instrumented with @@ -160,8 +166,7 @@ pub mod trace_service_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -184,7 +189,13 @@ pub mod trace_service_client { /// Generated server implementations. #[cfg(feature = "gen-tonic")] pub mod trace_service_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with TraceServiceServer. #[async_trait] @@ -325,17 +336,19 @@ pub mod trace_service_server { } _ => { Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", tonic::Code::Unimplemented as i32) - .header( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ) - .body(empty_body()) - .unwrap(), - ) + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) }) } } diff --git a/opentelemetry-proto/tests/grpc_build.rs b/opentelemetry-proto/tests/grpc_build.rs index b01c992c75..4039239b7c 100644 --- a/opentelemetry-proto/tests/grpc_build.rs +++ b/opentelemetry-proto/tests/grpc_build.rs @@ -125,7 +125,7 @@ fn build_tonic() { builder .out_dir(out_dir.path()) - .compile(TONIC_PROTO_FILES, TONIC_INCLUDES) + .compile_protos(TONIC_PROTO_FILES, TONIC_INCLUDES) .expect("cannot compile protobuf using tonic"); let after_build = build_content_map(out_dir.path(), true); diff --git a/scripts/patch_dependencies.sh b/scripts/patch_dependencies.sh index ead57c189f..cf36b55a98 100755 --- a/scripts/patch_dependencies.sh +++ b/scripts/patch_dependencies.sh @@ -1,14 +1,28 @@ #!/bin/bash -function patch_version() { - local latest_version=$(cargo search --limit 1 $1 | head -1 | cut -d'"' -f2) - echo "patching $1 from $latest_version to $2" - cargo update -p $1:$latest_version --precise $2 +# Function to compare two version numbers +function version_lt() { + [ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" != "$2" ] } -patch_version cc 1.0.105 -patch_version url 2.5.0 -patch_version hyper-rustls 0.27.2 # 0.27.3 needs rustc v1.70.0 -patch_version tokio-util 0.7.11 # 0.7.12 needs rustc v1.70.0 -patch_version tokio-stream 0.1.15 # 0.1.16 needs rustc v1.70.0 -patch_version tokio 1.38.0 # 1.39 needs msrv bump to rustc 1.70 +# Get the current Rust compiler version +rust_version=$(rustc --version | cut -d' ' -f2) + +# Target version (Rust 1.71.1) +target_version="1.71.1" + + function patch_version() { + local latest_version=$(cargo search --limit 1 $1 | head -1 | cut -d'"' -f2) + echo "patching $1 from $latest_version to $2" + cargo update -p $1:$latest_version --precise $2 + } + + patch_version cc 1.0.105 + patch_version url 2.5.0 +if version_lt "$rust_version" "$target_version"; then + patch_version tonic 0.12.2 + patch_version hyper-rustls 0.27.2 # 0.27.3 needs rustc v1.70.0 + patch_version tokio-util 0.7.11 # 0.7.12 needs rustc v1.70.0 + patch_version tokio-stream 0.1.15 # 0.1.16 needs rustc v1.70.0 + patch_version tokio 1.38.0 # 1.39 needs msrv bump to rustc 1.70 +fi