Skip to content

Telemetry instrumentation config for http_client headers#8349

Merged
bonnici merged 22 commits intodevfrom
njm/ROUTER-1068/subgraph-rhai-header-telemetry
Oct 7, 2025
Merged

Telemetry instrumentation config for http_client headers#8349
bonnici merged 22 commits intodevfrom
njm/ROUTER-1068/subgraph-rhai-header-telemetry

Conversation

@bonnici
Copy link
Contributor

@bonnici bonnici commented Sep 29, 2025

Adds a new telemetry instrumentation configuration for the http_client spans. This setting allows request headers added by Rhai scripts to be attached to the http_client span.

For example, with a Rhai script:

fn subgraph_service(service, subgraph) {
  let request_callback = |request| {
      print(`Subgraph service: Ready to send sub-operation to subgraph ${subgraph}`);
      request.subgraph.headers["some_rhai_request_header"] = "request-header-from-rhai";
  };
  
  let response_callback = |response| {
      print(`Subgraph service: Received sub-operation response from subgraph ${subgraph}`);
      response.headers["some_rhai_response_header"] = "response-header-from-rhai";
  };

  service.map_request(request_callback);
  service.map_response(response_callback);
}

The following configuration adds the some_rhai_request_header value to the http_client span. The some_rhai_response_header value is available on the subgraph span as before.

telemetry:
  instrumentation:
    spans:
      mode: spec_compliant
      subgraph:
        attributes:
          http.response.header.some_rhai_response_header:
            subgraph_response_header: "some_rhai_response_header"
      http_client:
        attributes:
          http.request.header.some_rhai_request_header:
            http_client_request_header: "some_rhai_request_header"

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 Sep 29, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 2 changed, 0 removed
* graphos/routing/(latest)/observability/router-telemetry-otel/enabling-telemetry/selectors.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/enabling-telemetry/spans.mdx

Build ID: c4f3c82b102b7882bca48036
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/c4f3c82b102b7882bca48036

@github-actions

This comment has been minimized.

@bonnici bonnici force-pushed the njm/ROUTER-1068/subgraph-rhai-header-telemetry branch 2 times, most recently from 3c582b4 to daa6c00 Compare September 29, 2025 01:40
@bonnici bonnici force-pushed the njm/ROUTER-1068/subgraph-rhai-header-telemetry branch from daa6c00 to 9fb698f Compare September 29, 2025 01:42
@bonnici bonnici changed the title WIP http_client telemetry selectors Telemetry instrumentation config for http_client headers Sep 29, 2025
@bonnici bonnici marked this pull request as ready for review September 29, 2025 04:58
@bonnici bonnici requested a review from a team September 29, 2025 04:58
@bonnici bonnici requested a review from a team as a code owner September 29, 2025 04:58
@abernix abernix requested a review from BrynCooke September 29, 2025 12:09
Copy link
Contributor

@BrynCooke BrynCooke left a comment

Choose a reason for hiding this comment

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

Looks great, only a couple of renames and selectors.mdx needs updating.

@bonnici bonnici requested review from a team as code owners September 30, 2025 22:44
@bonnici bonnici requested a review from a team as a code owner September 30, 2025 22:44
@bonnici bonnici closed this Sep 30, 2025
@bonnici bonnici reopened this Sep 30, 2025
@bonnici bonnici removed request for a team September 30, 2025 22:48
@bonnici bonnici requested a review from BrynCooke October 2, 2025 02:24
Copy link
Contributor

@BrynCooke BrynCooke left a comment

Choose a reason for hiding this comment

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

@bonnici bonnici merged commit f474941 into dev Oct 7, 2025
15 checks passed
@bonnici bonnici deleted the njm/ROUTER-1068/subgraph-rhai-header-telemetry branch October 7, 2025 03:35
@abernix abernix mentioned this pull request Oct 27, 2025
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.

4 participants