Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OtelGrpcLayer + another layer #109

Open
vmorarian opened this issue Nov 14, 2023 · 1 comment
Open

OtelGrpcLayer + another layer #109

vmorarian opened this issue Nov 14, 2023 · 1 comment

Comments

@vmorarian
Copy link

Hi,

I'm experimenting with examples and it looks like that composing of layer doesn't work (or I'm missing something).
Basically updated client

let channel = ServiceBuilder::new().layer(OtelGrpcLayer).service(channel);

by adding timeout layer

    let channel = ServiceBuilder::new()
        .timeout(std::time::Duration::from_secs(10)) // <<< new layer
        .layer(OtelGrpcLayer)
        .service(channel);

and it doesn't compile, getting:

error[E0277]: the trait bound `tonic_tracing_opentelemetry::middleware::client::OtelGrpcService<Channel>: Service<request::Request<http_body::combinators::box_body::UnsyncBoxBody<prost::bytes::Bytes, tonic::Status>>>` is not satisfied
  --> examples/grpc/src/client.rs:26:22
   |
26 |     let mut client = GreeterClient::new(channel);
   |                      ^^^^^^^^^^^^^^^^^^ the trait `Service<request::Request<http_body::combinators::box_body::UnsyncBoxBody<prost::bytes::Bytes, tonic::Status>>>` is not implemented for `tonic_tracing_opentelemetry::middleware::client::OtelGrpcService<Channel>`
   |
   = help: the following other types implement trait `Service<Request>`:
             <MakeBalance<S, Req> as Service<Target>>
             <hyper_timeout::TimeoutConnector<T> as Service<Uri>>
             <Balance<D, Req> as Service<Req>>
             <GreeterServer<T> as Service<request::Request<B>>>
             <tonic_tracing_opentelemetry::middleware::server::OtelGrpcService<S> as Service<request::Request<B>>>
             <Pool<MS, Target, Req> as Service<Req>>
             <Box<S> as Service<Request>>
             <axum::error_handling::HandleError<S, F, ()> as Service<request::Request<B>>>
           and 116 others
   = note: required for `tower::timeout::Timeout<tonic_tracing_opentelemetry::middleware::client::OtelGrpcService<Channel>>` to implement `Service<request::Request<http_body::combinators::box_body::UnsyncBoxBody<prost::bytes::Bytes, tonic::Status>>>`
   = note: required for `tower::timeout::Timeout<tonic_tracing_opentelemetry::middleware::client::OtelGrpcService<Channel>>` to implement `GrpcService<http_body::combinators::box_body::UnsyncBoxBody<prost::bytes::Bytes, tonic::Status>>`

error[E0599]: the method `say_hello` exists for struct `GreeterClient<Timeout<OtelGrpcService<Channel>>>`, but its trait bounds were not satisfied
   |
  ::: /Users/vitaliy/github/tracing-opentelemetry-instrumentation-sdk/target/debug/build/examples-grpc-bf009df384ee5b81/out/helloworld.rs:19:5
   |
19 |     pub struct GreeterClient<T> {
   |     --------------------------- method `say_hello` not found for this struct
  --> examples/grpc/src/client.rs:32:27
   |
32 |     let response = client.say_hello(request).await?;
   |                           ^^^^^^^^^ method cannot be called on `GreeterClient<Timeout<OtelGrpcService<Channel>>>` due to unsatisfied trait bounds
   |
  ::: /Users/vitaliy/github/tracing-opentelemetry-instrumentation-sdk/tonic-tracing-opentelemetry/src/middleware/client.rs:33:1
   |
33 | pub struct OtelGrpcService<S> {
   | ----------------------------- doesn't satisfy `_: Service<Request<UnsyncBoxBody<Bytes, Status>>>`
   |
  ::: /Users/vitaliy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/timeout/mod.rs:19:1
   |
19 | pub struct Timeout<T> {
   | ---------------------
   | |
   | doesn't satisfy `<_ as Service<Request<UnsyncBoxBody<Bytes, Status>>>>::Response = Response<_>`
   | doesn't satisfy `_: GrpcService<UnsyncBoxBody<Bytes, Status>>`
   | doesn't satisfy `_: Service<Request<UnsyncBoxBody<Bytes, Status>>>`
   |
note: trait bound `tower::timeout::Timeout<tonic_tracing_opentelemetry::middleware::client::OtelGrpcService<Channel>>: GrpcService<http_body::combinators::box_body::UnsyncBoxBody<prost::bytes::Bytes, tonic::Status>>` was not satisfied
  --> /Users/vitaliy/github/tracing-opentelemetry-instrumentation-sdk/target/debug/build/examples-grpc-bf009df384ee5b81/out/helloworld.rs:35:12
   |
33 |     impl<T> GreeterClient<T>
   |             ----------------
34 |     where
35 |         T: tonic::client::GrpcService<tonic::body::BoxBody>,
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound introduced here
   = note: the following trait bounds were not satisfied:
           `<tower::timeout::Timeout<tonic_tracing_opentelemetry::middleware::client::OtelGrpcService<Channel>> as Service<request::Request<http_body::combinators::box_body::UnsyncBoxBody<prost::bytes::Bytes, tonic::Status>>>>::Response = response::Response<_>`
           `tower::timeout::Timeout<tonic_tracing_opentelemetry::middleware::client::OtelGrpcService<Channel>>: Service<request::Request<http_body::combinators::box_body::UnsyncBoxBody<prost::bytes::Bytes, tonic::Status>>>`
           `tonic_tracing_opentelemetry::middleware::client::OtelGrpcService<Channel>: Service<request::Request<http_body::combinators::box_body::UnsyncBoxBody<prost::bytes::Bytes, tonic::Status>>>`

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `examples-grpc` (bin "client") due to 2 previous errors

Am I missing something?

@bpoweski
Copy link

double check you're importing from client vs server, I saw a similar error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants