google / tarpc

An RPC framework for Rust with a focus on ease of use.
MIT License
3.18k stars 194 forks source link

Server-side span with client’s span as parent #406

Closed 3XX0 closed 8 months ago

3XX0 commented 1 year ago

The documentation for tarpc::trace::Context mentions:

span_id: SpanId An identifier of the current span. In typical RPC usage, a span is created by a client before making an RPC, and the span ID is sent to the server. The server is free to create its own spans, for which it sets the client’s span as the parent span.

How does it work in practice? It doesn't look like there are helpers in Context to go from tarpc::trace::SpanId to tracing::span::Id

Is the following correct or am I missing something?

#[tarpc::server]
impl World for HelloServer {
    #[tracing::instrument(parent = tracing::span::Id::from_u64(ctx.trace_context.span_id.into()), skip_all)]
    async fn hello(self, ctx: context::Context, name: String) -> String {
        ...
    }
 }

SpanExt might actually be what I need but this is not exposed unfortunately.

tikue commented 1 year ago

Hi! In practice tarpc instruments the server-side span like this for you, so you shouldn't have to do anything.

Is it not working as expected?

tikue commented 8 months ago

Closing this due to lack of activity, but please feel free to reopen if you have further questions. Thanks!

davidcaseria commented 7 months ago

Hi, I don't think this is working correctly, or I am misusing either this library or the tracing library. What is the best way to go about debugging this? Thanks!

wahtique commented 3 months ago

Hi @tikue ! I have a use case which would be solved by making context::SpanExt and its impl for tracing::Span public. Would you be open to this change ? Thanks !