-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Restful logs HTTP requests and responses separately. That is different from most FOSS components, that log those together on a single line. The upside of Restful's behavior is that the log is printed in sync with all the other logs the app prints. The downside is that you cannot easily correlate requests and responses.
To tackle that issue Restful prints a correlation ID. If tracing is active, then that ID contains the trace ID. As OTel generates client span when the HTTP client object sends the request, i.e. OTel instruments the transport of the http.Client, Restful cannot grab that. Unless it inserts itself into the transport, which does not happen at the moment. Instead, at the time of the writing, Restful generates an extra span for each request and prints its ID to the log. That is not the optimal approach, as the traces are littered with extra spans, and the logs cannot be precisely correlated with the real transport spans in a tcpdump.
Restful could be improved in 2 steps:
- Let OTel insert the correlation trace + span IDs to the logs. As Restful uses Logrus, use
logrus.WithContext(). - That does not resolve the client log correlation issue, as the span ID is still missing. Restful client log should be on transport level where OTel inserted headers are available.
Note: The app should activate Logrus OTel hooks for log collection.