tonic
tonic copied to clipboard
Parent spans at the middleware using OpenTelemetry
Bug Report
Version
└── tonic v0.6.2 └── tonic-build v0.6.2 ├── tonic v0.6.2 (*)
Platform
MINGW64_NT-10.0-19043 3.1.7-340.x86_64 2021-03-26 22:17 UTC x86_64 Msys
Description
I tried to create spans using OpenTelemetry, tonic, and tower-http.
However, I couldn't create a parent span at the middleware.
I prepared my simple example.

I expected to see one span.
P.S. Maybe I did something wrong.
I think the issue is related to tonic using tower::buffer::Buffer internally and perhaps not propagating the spans correctly but have to do some digging to make sure.
@davidpdrsn tower::buffer::Buffer is supposed to propagate spans https://docs.rs/tower/latest/src/tower/buffer/service.rs.html#148-151, so I'd be surprised if that's the issue
Ah okay. Hm then I dunno what's wrong here 😅
@davidpdrsn tower::buffer::Buffer is supposed to propagate spans https://docs.rs/tower/latest/src/tower/buffer/service.rs.html#148-151, so I'd be surprised if that's the issue
tower::buffer::Buffer is propagating a tracing::Span, but @arttet is creating an OpenTelemetry span. @arttet: my suggestion is to not directly create OpenTelemetry Spans but instead creating tracing::Spans. tracing_opentelemetry will handle the conversion for you and propagate things correctly.