-
Notifications
You must be signed in to change notification settings - Fork 114
Description
Feature Request
Often the trace parent information is only available after some processing steps, e.g. in HTTP you might first accept the TCP connection, then possibly do a TLS handshake, then create some per connection state objects and only then parse the HTTP headers with the trace parent.
It would be useful if there was a way to delay the submission of the request root span and all its child spans until that point so it can be submitted with the correct trace id from the trace parent header or similar information in other protocols or until we can explicitly tell it that there is no trace parent information in the request.
It might also be useful to have an easy way to access the (request) root span from the current span.
Motivation
Currently the alternative is setting the trace parent on the span that is the current span at the time that information becomes accessible but that cuts off all the previous parents on one hand and also attributes some more time to the process sending the trace parent header because the timing information from those previous parents is not shown as part of the distributed trace.
Proposal
The drawback would be some more complexity in the submission logic if it had to delay some spans and of course those spans would not be available at all if the code never reaches that point where it tries to extract trace parent information from the request.
Alternatives
The OpenTelemetry project could create a message that links two existing trace ids so they are displayed as one trace anyway. Considering how many implementations there are the use of that would likely take a while to spread to a state where that would become useful.