Skip to content

Log request origins - #941

Merged
abcampo-iry merged 1 commit into
mainfrom
issues/1588
Jul 28, 2026
Merged

Log request origins#941
abcampo-iry merged 1 commit into
mainfrom
issues/1588

Conversation

@abcampo-iry

@abcampo-iry abcampo-iry commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Status

What's changed?

  • Adds the request Origin header to the structured completed-request payload.
  • Applies the logging to requests through ApiController.
  • Adds request specs covering requests with and without an Origin header.
  • Makes the origin available for filtering and grouping request logs in Better Stack.

Copilot AI review requested due to automatic review settings July 27, 2026 15:25
@cla-bot cla-bot Bot added the cla-signed label Jul 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds request Origin header data into Rails’ controller instrumentation payload for API requests, enabling downstream structured logging (via Semantic Logger) to filter/group by request origin as requested in issue #1588.

Changes:

  • Append origin to the process_action.action_controller payload for controllers inheriting from ApiController when the header is present.
  • Add request specs asserting the payload includes origin when provided and omits it otherwise.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
app/controllers/api_controller.rb Overrides append_info_to_payload to include origin in the controller instrumentation payload when present.
spec/requests/api_controller_spec.rb Adds request specs that subscribe to process_action.action_controller and validate presence/absence of the origin payload field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

Test coverage

92.18% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/30279908881

@raspberrypiherokubot
raspberrypiherokubot temporarily deployed to editor-api-p-issues-158-fp2o1v July 27, 2026 15:32 Inactive
@abcampo-iry abcampo-iry changed the title Log request origins in Editor API structured logs Log request origins in Editor API Jul 28, 2026
@abcampo-iry abcampo-iry changed the title Log request origins in Editor API Log request origins Jul 28, 2026

@zetter-rpf zetter-rpf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, it's good to have an example of how to add something to the logs too.

I can deploy and check betterstack once merged.

@abcampo-iry
abcampo-iry merged commit 8a71b7c into main Jul 28, 2026
7 checks passed
@abcampo-iry
abcampo-iry deleted the issues/1588 branch July 28, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants