Skip to content

feat: Add structured logging for requests made to DCR and CAPI - #28983

Closed
akash1810 wants to merge 3 commits into
mainfrom
aa/capi-dcr-request-logging
Closed

feat: Add structured logging for requests made to DCR and CAPI#28983
akash1810 wants to merge 3 commits into
mainfrom
aa/capi-dcr-request-logging

Conversation

@akash1810

@akash1810 akash1810 commented Jul 22, 2026

Copy link
Copy Markdown
Member

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: RequestHeader which isn't available in ContentApiClient.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:

image

Checklist

@akash1810 akash1810 added the feature Departmental tracking: work on a new feature label Jul 22, 2026
@akash1810
akash1810 force-pushed the aa/capi-dcr-request-logging branch from 833c91b to 1ac4ac3 Compare July 22, 2026 15:39
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

To better distinguish between these logs and logs from the request logger.
@akash1810
akash1810 force-pushed the aa/capi-dcr-request-logging branch from 3dea2cf to 90a034c Compare July 22, 2026 20:18
@akash1810
akash1810 marked this pull request as ready for review July 23, 2026 09:10
@akash1810
akash1810 requested a review from a team as a code owner July 23, 2026 09:10
@akash1810
akash1810 marked this pull request as draft July 23, 2026 12:27
@akash1810

Copy link
Copy Markdown
Member Author

Superseded by #28984. Closing.

@akash1810 akash1810 closed this Jul 23, 2026
@akash1810
akash1810 deleted the aa/capi-dcr-request-logging branch July 23, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Departmental tracking: work on a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant