Skip to content

Conversation

@calvincestari
Copy link
Member

@calvincestari calvincestari commented Oct 28, 2025

At the moment we have a split between two closely related features; the Client Awareness feature is activated through HTTP headers, whereas Enhanced Client Awareness is activated through request.extensions. The long-term goal for these two has always been to enable a common transport for them. So that they can both be sent via HTTP headers, or request.extensions.

This PR enables that:

  • The enhanced_client_awareness plugin now looks for client name/version and adds it to the request context and those values get sent off in the metrics report.
  • The telemetry plugin now looks for the library name/version and adds it to the request context and those values get sent off in the metrics report.

https://apollographql.atlassian.net/browse/ROUTER-1520


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-librarian
Copy link

apollo-librarian bot commented Oct 28, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 1eab6ad149a2879ed83e5e26
Build Logs: View logs

@github-actions

This comment has been minimized.

@calvincestari calvincestari force-pushed the feature/client-awareness-common-transport branch from 1b34917 to bfbb873 Compare October 30, 2025 17:47
@calvincestari calvincestari marked this pull request as ready for review November 6, 2025 01:04
@calvincestari calvincestari requested review from a team as code owners November 6, 2025 01:04
@calvincestari calvincestari requested a review from bonnici November 6, 2025 01:04
@@ -0,0 +1,5 @@
### ([PR #8503](https://github.com/apollographql/router/pull/8503))

Supporting a common transport mechanism for the Client Awareness and Enhanced Client Awareness values is more efficient than the current split between HTTP header (for Client Awareness) and `request.extensions` for Enhanced Client Awareness. This changeset allows clients to send both sets of values using the same method.
Copy link

Choose a reason for hiding this comment

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

Q: which one 'wins' if for instance clientLibrary is provided both in headers and in extensions?

Copy link
Member Author

Choose a reason for hiding this comment

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

My assumption is the extensions plugin would overwrite any header values but I'm not certain; I'd need to check the order of request processing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Circling back to this - I believe my assumption is correct.

  • Looking at the request lifecycle detailed in the Router docs the router service is before the supergraph service.
  • The telemetry plugin is registered for interaction with many services but the one that handles the client name/version extraction is in the router service logic - here
  • The enhanced client awareness plugin in registered only for interaction with the supergraph service - here

Copy link

Choose a reason for hiding this comment

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

Thanks a lot for confirming. I guess it should be documented somewhere (not sure where!) to avoid any mixup.

@calvincestari
Copy link
Member Author

@apollographql/router-core, @bonnici - would love a review on this PR when you get a free moment please, thank you.

Copy link
Contributor

@bonnici bonnici left a comment

Choose a reason for hiding this comment

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

The changes look good to me, but from memory the reason we went with using request.extensions was to make it hard for people to modify the library name and version. Adding user-configurable options for deciding which header values to use for this seems to go against that goal. But if we've decided that this is the way we want to go, we should also update the docs here: https://www.apollographql.com/docs/graphos/routing/observability/router-telemetry-otel/enabling-telemetry/usage-guides/client-id-enforcement

@calvincestari
Copy link
Member Author

The changes look good to me, but from memory the reason we went with using request.extensions was to make it hard for people to modify the library name and version. Adding user-configurable options for deciding which header values to use for this seems to go against that goal.

It wasn't necessarily to make it more difficult but rather that using HTTP headers and being on-by-default would have negative consequences for web applications re. CORS. All clients offer a way to disable sending the library values but use hard-coded values, so the only way for an app to modify the values would be to modify the request after it has been composed.

This change now is to clean up the inefficient split sending methods in use today and support a couple recent use cases.

But if we've decided that this is the way we want to go, we should also update the docs here: https://www.apollographql.com/docs/graphos/routing/observability/router-telemetry-otel/enabling-telemetry/usage-guides/client-id-enforcement

Thanks for the prompt about the docs. I'll get those updated.

@calvincestari
Copy link
Member Author

calvincestari commented Nov 10, 2025

@bonnici, looking into the documentation now is making me question whether customers that choose to send client name and version via request.extensions would be losing trace data? I say this because the changes I've made ensure that the metrics report gets the values regardless of where they originate from (headers vs. extensions) but I haven't accounted for the missing trace report values if they aren't in the http header.

The section titled "Why enforce client reporting?" lists a few items and I'm not certain of where they are derived from: client field usage; traffic patterns; and operation-level observability. Do you know which of those are derived from traces vs. metrics?

@calvincestari
Copy link
Member Author

Putting this PR back into 'draft' while I update the documentation and figure out the trace report questions..

@calvincestari calvincestari marked this pull request as draft November 10, 2025 23:08
@bonnici
Copy link
Contributor

bonnici commented Nov 12, 2025

I'll need to look into this tomorrow.

@calvincestari
Copy link
Member Author

I'm going to add test for client name/version via request extensions + trace report, so I'll have to get that logic path working too.

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