LukeMathWalker/tracing-actix-web

Missing trace_id value in REQUEST - START

oriontvv opened this issue · 1 comments

Hello, many thanks for this crate!
It looks like DefaultRootSpanBuilder doesn't insert trace_id value in the REQUEST - START span. Next spans do it fine. Maybe trace_id extracting inside set_otel_parent should be before calling inner_span in root_span macro?
Is this behaviour intentional or we can fix it?
You can reproduce this with examples/opentelemetry example:

$ curl -v http://localhost:8080/hello --header "traceparent:00-80e1afed08e019fc1110464cfa66635c-7a085853722dc6d2-01"
{"v":0,"name":"tracing-actix-web-demo","msg":"[HTTP REQUEST - START]","level":30,"hostname":"macbook-C02G91XWMD6R","pid":72599,"time":"2023-07-06T17:01:00.931497Z","target":"tracing_actix_web::root_span_builder","line":54,"file":"src/root_span_builder.rs","http.scheme":"http","request_id":"8f96e234-264b-493d-89c3-842c927e85d3","http.client_ip":"127.0.0.1","http.route":"/hello","http.user_agent":"curl/7.88.1","http.target":"/hello","http.flavor":"1.1","otel.kind":"server","http.method":"GET","otel.name":"HTTP GET /hello","http.host":"localhost:8080"}

{"v":0,"name":"tracing-actix-web-demo","msg":"[HTTP REQUEST - END]","level":30,"hostname":"macbook-C02G91XWMD6R","pid":72599,"time":"2023-07-06T17:01:00.931786Z","target":"tracing_actix_web::root_span_builder","line":54,"file":"src/root_span_builder.rs","request_id":"8f96e234-264b-493d-89c3-842c927e85d3","http.route":"/hello","http.user_agent":"curl/7.88.1","http.target":"/hello","http.flavor":"1.1","http.status_code":200,"http.method":"GET","http.host":"localhost:8080","http.scheme":"http","http.client_ip":"127.0.0.1","elapsed_milliseconds":0,"otel.status_code":"OK","otel.kind":"server","trace_id":"80e1afed08e019fc1110464cfa66635c","otel.name":"HTTP GET /hello"}

I'm fuzzy on the details, but I seem to recall that it's not easy/straight-forward to extract it before creating the span.
If you manage to, happy to merge it in!