feat: Add headers to understand who responded#16384
Conversation
|
Hello 👋! When you're ready to run Chromatic, please apply the You will need to reapply the label each time you want to run Chromatic. |
9a64caa to
bddbffc
Compare
1b99e65 to
1d85b94
Compare
0f02936 to
127c7a2
Compare
There was a problem hiding this comment.
Pull request overview
Adds a reusable Express middleware to stamp responses with backend-identification headers so downstream tooling can tell which DCR app and which infrastructure target group (EC2 vs ECS) served a request. This supports traffic-splitting/verification work (e.g., ECS rollout) by making the responder visible in each HTTP response.
Changes:
- Introduce
responseHeaderMiddlewarethat setsX-Gu-Backend-AppandX-Gu-Backend-App-Target-Group. - Register the middleware in both production and development servers so headers are applied to responses.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dotcom-rendering/src/server/server.prod.ts | Registers the new response-header middleware for prod server responses. |
| dotcom-rendering/src/server/server.dev.ts | Registers the new response-header middleware for dev renderer routes. |
| dotcom-rendering/src/server/lib/header-middleware.ts | Implements the middleware and environment-derived header values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b846f91 to
8a0393c
Compare
7d762ad to
d432382
Compare
This change adds two headers to each response: - `X-Gu-Backend-App` which represents which app is running (tag-page-rendering, article-rendering, etc.) - `X-Gu-Backend-App-Target-Group` which represents which target group served the request (EC2 or ECS) One use-case for this is in the "run DCR on ECS" project. This is similar to `guardian/frontend`, see https://github.com/guardian/frontend/blob/0cbc1c8448d6afb74eab75903b16a224fbcf1114/common/app/http/Filters.scala#L49-L62.
Other places in the repository fallback to "rendering". Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
d432382 to
43ec374
Compare
|
Seen on PROD (merged by @akash1810 13 minutes and 24 seconds ago) Please check your changes! |
What does this change?
This change adds two headers to each response:
X-Gu-Backend-Appwhich represents which app is running (tag-page-rendering, article-rendering, etc.)X-Gu-Backend-App-Target-Groupwhich represents which target group served the request (EC2 or ECS)One use-case for this is in the "run DCR on ECS" project (see also #16321).
This is similar to guardian/frontend.
X-Gu-Backend-Appis already removed for reader requests within Fastly.X-Gu-Backend-App-Target-Groupis removed in https://github.com/guardian/fastly-edge-cache/pull/1199.Why?
As part of @guardian/devx-reliability-and-ops's project to run DCR on AWS, we'll be splitting traffic between the current EC2 target group and the new ECS target group. This header helps to distinguish what infrastructure responded.
How has this change been tested?
After deploying to CODE and following the steps listed in #16377, we can see the new headers: