Skip to content

add ResponseErrors selector to router response#7882

Closed
Aguilarjaf wants to merge 11 commits intoapollographql:devfrom
ExpediaGroup:add-response-body-fields
Closed

add ResponseErrors selector to router response#7882
Aguilarjaf wants to merge 11 commits intoapollographql:devfrom
ExpediaGroup:add-response-body-fields

Conversation

@Aguilarjaf
Copy link
Contributor

@Aguilarjaf Aguilarjaf commented Jul 11, 2025

Introducing the ResponseErrors selector in telemetry configurations to capture router response errors, allowing users to capture and log errors encountered at the router service layer. This new selector enhances logging for the router service, as it allows users the option to only log router errors instead of the entire router response body to reduce noise.

telemetry:
  instrumentation:
    events:
      router:
         router.error:
            attributes:
               "my_attribute":
                   response_errors: "$.[0]"
                   # Examples: "$.[0].message", "$.[0].locations", "$.[0].extensions", etc.

Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • PR description explains the motivation for the change and relevant context for reviewing
  • PR description links appropriate GitHub/Jira tickets (creating when necessary)
  • Changeset is included for user-facing changes
  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit tests
    • Integration tests
    • Manual tests, as necessary

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@apollo-cla
Copy link

@Aguilarjaf: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@apollo-librarian
Copy link

apollo-librarian bot commented Jul 11, 2025

❌ Docs preview failed

The preview failed to build.

Build ID: 91d0b0ccea4199e8407777d4

Errors

General: Failed to fetch GitHub source: OK

@Aguilarjaf Aguilarjaf marked this pull request as ready for review July 11, 2025 20:07
@Aguilarjaf Aguilarjaf requested a review from a team July 11, 2025 20:07
@goto-bus-stop
Copy link
Member

goto-bus-stop commented Jul 15, 2025

Elsewhere we use JSON Path to select subsets of data from the response_data and response_errors selectors:
https://www.apollographql.com/docs/graphos/routing/observability/telemetry/instrumentation/selectors#setting-json-paths

I think it makes sense to have a feature like this in response_body, but I think it should also use JSON Path to match the existing functionality.
(You might also already be able to achieve what you need with those other selectors!)

@Aguilarjaf
Copy link
Contributor Author

Hi @goto-bus-stop, thanks for the feedback!

I have updated the PR to better align with the best practice of using JSON Path to select a subset of data from the router response. I have implemented an additional selector, ResponseErrors, that takes a JsonPathInst object to extract specific information from router response errors (message, extensions, etc.). This is functionality currently does not exist in the router service response, so providing a new selector such as ResponseErrors can help users better capture and log those router level errors.

@Aguilarjaf Aguilarjaf changed the title add truncate field to response body add ResponseErrors selector to router response Jul 18, 2025
@Aguilarjaf Aguilarjaf requested a review from Velfi July 21, 2025 18:05
@Aguilarjaf Aguilarjaf requested a review from a team as a code owner July 22, 2025 22:49
@Velfi
Copy link
Contributor

Velfi commented Jul 30, 2025

@Mergifyio copy dev

@mergify
Copy link
Contributor

mergify bot commented Jul 30, 2025

copy dev

❌ No copy have been created

Details
  • Copy to branch dev failed

Git reported the following error:

error: commit 4a3f2a2585b6c1f3433031bdf55175eb41f9364f is a merge but no -m option was given.
fatal: cherry-pick failed

@mergify mergify bot mentioned this pull request Jul 31, 2025
10 tasks
@abernix
Copy link
Member

abernix commented Jul 31, 2025

We'll close this in lieu of #8024, where you're welcome to help contribute to the conversation in getting it over the line but will no longer have branch push perms. Thanks much for getting this opened and started originally — you'll still get contribution credit via that other PR when it merges, but we'll be able to run this with the full CI from that PR via @Velfi's account. Thanks again to you both!

@abernix abernix closed this Jul 31, 2025
@abernix abernix mentioned this pull request Sep 22, 2025
@abernix
Copy link
Member

abernix commented Sep 22, 2025

This is shipping Router v2.7.0 — which has its release candidate up now as https://github.com/apollographql/router/releases/tag/v2.7.0-rc.0. It should be released officially in the next couple days.

Thanks again for the original contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants