Skip to content

Logging and client trace correlation #107

@Som-Som-CC

Description

@Som-Som-CC

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:

  1. Let OTel insert the correlation trace + span IDs to the logs. As Restful uses Logrus, use logrus.WithContext().
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions