tonic icon indicating copy to clipboard operation
tonic copied to clipboard

Parent spans at the middleware using OpenTelemetry

Open arttet opened this issue 2 years ago • 4 comments

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.

2022-02-22_14-14-41

I expected to see one span.

P.S. Maybe I did something wrong.

arttet avatar Feb 22 '22 11:02 arttet

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 avatar Feb 22 '22 11:02 davidpdrsn

@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

olix0r avatar Feb 24 '22 17:02 olix0r

Ah okay. Hm then I dunno what's wrong here 😅

davidpdrsn avatar Feb 24 '22 17:02 davidpdrsn

@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.

davidbarsky avatar Feb 28 '22 19:02 davidbarsky