feat: Add structured logging for requests made to DCR and CAPI - #28983
Closed
akash1810 wants to merge 3 commits into
Closed
feat: Add structured logging for requests made to DCR and CAPI#28983akash1810 wants to merge 3 commits into
akash1810 wants to merge 3 commits into
Conversation
akash1810
force-pushed
the
aa/capi-dcr-request-logging
branch
from
July 22, 2026 15:39
833c91b to
1ac4ac3
Compare
Contributor
To better distinguish between these logs and logs from the request logger.
akash1810
force-pushed
the
aa/capi-dcr-request-logging
branch
from
July 22, 2026 20:18
3dea2cf to
90a034c
Compare
akash1810
marked this pull request as ready for review
July 23, 2026 09:10
akash1810
marked this pull request as draft
July 23, 2026 12:27
7 tasks
Member
Author
|
Superseded by #28984. Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change?
This change adds a log after making a GET request to CAPI or a POST request to DCR. The log line is structured, with markers covering the URL, response code, content length and request duration. We can use this to monitor the performance of these requests and identify any issues with them.
I've attempted to namespace the markers to distinguish them from the request logs.
For example, in the project to run DCR on ECS, we've been doing some load testing to right-size the ECS cluster.
Whilst doing this, we've noticed the latency of a request is sometimes unexpectedly high.
In guardian/dotcom-rendering#16408, we've added tracing and the results show a significant time is spent reading the POST body and parsing it as JSON.
We've a hypothesis that payload POSTed to DCR is a superset of what it needs (see also #28964 and #27894).
These logs should help us graph the size of the payload and the time taken to read it, so we can see if there's a correlation between the two.
Note
Ideally, we'd log the request-id as a marker too as that would allow us to relate a CAPI log line with a DCR log line. There are some helpers for this, however it requires an
implicit headers: RequestHeaderwhich isn't available inContentApiClient.scala.I couldn't cleanly satisfy this requirement, so I've left it out for now. My Scala is pretty rusty these days, so any help is most welcomed!
Screenshots
After deploying to CODE, we can see the logs in Central ELK:
Checklist
data/databasefiles generated by tests are committed with this PR (the tests will fail in CI if you've forgotten to do this)