Pass interface and client information to AI Gateway

What does this MR do and why?

This MR allows frontend clients to pass X-Gitlab-Client-Type, X-Gitlab-Client-Version, X-Gitlab-Client-Name and X-Gitlab-Interface headers to the GraphQL AiAction mutation and pass it to AI Gateway endpoints for InternalEvent tracking (See feat(internal event): track client_name, client... (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!1960 - merged))).

Closes Pass interface and client information from duo ... (#518051 - closed)

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Confirmed that the header values are passed to AI Gateway:

GraphQL AiAction mutation sent from Frontend :

shinya@shinya-XPS-15-9530:~/gdk$ curl "http://gdk.test:3000/api/graphql" --header "Authorization: Bearer glpat-"      --header "Content-Type: application/json"      --header "X-Gitlab-Client-Type: abc"      --header "X-Gitlab-Client-Version: def"      --header "X-Gitlab-Client-Name: ghi"      --header "X-Gitlab-Interface: jkl"      --request POST      --data "{\"query\": \"mutation { aiAction( input: { chat: { resourceId: \\\"gid://gitlab/User/1\\\", content: \\\"How can I create an issue?\\\" } } ){ requestId errors } }\"}"

Logged headers in AI Gateway:

{
  "correlation_id": "01JKYTX8Q36HF379V7346ZD3BR",
  "logger": "api.access",
  "level": "info",
  "type": "mlops",
  "stage": "main",
  "timestamp": "2025-02-13T05:01:12.552319Z",
  "message": "request.headers: Headers({'x-gitlab-authentication-type': 'oidc', 'authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJraWQiOiJUYk1LQVpLU2xZbVRneFdaVkIyZnhFZlVMZXppLVk5NDdwQU5ubEw2WWJZIiwiYWxnIjoiUlMyNTYifQ.eyJqdGkiOiI0YmY1MzdjNi0xZTBhLTQ0NWUtYjZmOC03NGE1MWMwOWJhNjAiLCJhdWQiOiJnaXRsYWItYWktZ2F0ZXdheSIsInN1YiI6IjdmNzlkMzY0LWY0YmItNGI5Ni05ZDlhLTc2ZDQ0MmMyMjVlOCIsImlzcyI6Imh0dHA6Ly9nZGsudGVzdDozMDAwIiwiaWF0IjoxNzM5NDIyODcyLCJuYmYiOjE3Mzk0MjI4NjcsImV4cCI6MTczOTQyNjQ3MiwiZ2l0bGFiX3JlYWxtIjoic2VsZi1tYW5hZ2VkIiwic2NvcGVzIjpbImFza19idWlsZCIsImFza19jb21taXQiLCJhc2tfZXBpYyIsImFza19pc3N1ZSIsImFza19tZXJnZV9yZXF1ZXN0IiwiZG9jdW1lbnRhdGlvbl9zZWFyY2giLCJkdW9fY2hhdCIsImV4cGxhaW5fY29kZSIsImV4cGxhaW5fdGVybWluYWwiLCJmaXhfY29kZSIsImluY2x1ZGVfZGVwZW5kZW5jeV9jb250ZXh0IiwiaW5jbHVkZV9maWxlX2NvbnRleHQiLCJpbmNsdWRlX2lzc3VlX2NvbnRleHQiLCJpbmNsdWRlX2xvY2FsX2dpdF9jb250ZXh0IiwiaW5jbHVkZV9tZXJnZV9yZXF1ZXN0X2NvbnRleHQiLCJpbmNsdWRlX3NuaXBwZXRfY29udGV4dCIsInJlZmFjdG9yX2NvZGUiLCJ3cml0ZV90ZXN0cyJdfQ.ocW9X6Tt1LJhBSqekqAo4izT_BuThU7CWw_TIHE8FXZPQ7CVIassNlBtKlWeEk4ZiZSx1H_rJdhipeRDqcUtk2AjX_VUEfioCNsaosQRFhQxyYU735z_ewXf8ZmJhRRZVFQNuAx_NM_tnt_VB-U7vlpVPYZSyGfWrkCeLAdRrwZgjU929mEyqo-oKRvp_nOjP5G7MtqIYBUJyQCAhSNH7zWekd7fk3IDqu1ZiwPioWOyW3peMLedgdnoaL23m37aynCVd6eivjHBIDTvilqq11LDZJC7nmasmTTRb0ElvlOqFOw0mUoCmgz3nb5JtdQMjdO9RjcDEo4JeHcvheUBTw', 'content-type': 'application/json', 'x-gitlab-is-team-member': 'false', 'x-request-id': '01JKYTX8Q36HF379V7346ZD3BR', 'x-gitlab-rails-send-start': '1739422872.540375', 'x-gitlab-feature-enablement-type': 'add_on', 'x-gitlab-enabled-feature-flags': 'ai_commit_reader_for_chat,expanded_ai_logging', 'x-gitlab-host-name': 'gdk.test', 'x-gitlab-instance-id': '7f79d364-f4bb-4b96-9d9a-76d442c225e8', 'x-gitlab-realm': 'self-managed', 'x-gitlab-version': '17.9.0', 'x-gitlab-global-user-id': '+nX6PXalgNf3sEoS6tYAyV1uZzoSNUq1Y6NWOcfnbTc=', 'x-gitlab-duo-seat-count': '100', 'x-gitlab-feature-enabled-by-namespace-ids': '', 'x-gitlab-client-type': 'abc', 'x-gitlab-client-version': 'def', 'x-gitlab-client-name': 'ghi', 'x-gitlab-interface': 'jkl', 'langsmith-trace': '20250213T050112Ze7fafbf3-6df6-446e-8af0-457b463cc967', 'accept-encoding': 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'accept': '*/*', 'user-agent': 'Ruby', 'connection': 'close', 'host': 'localhost:5052', 'content-length': '11087'})"
}
{
  "correlation_id": "01JKYTX8Q36HF379V7346ZD3BR",
  "logger": "api.access",
  "level": "info",
  "type": "mlops",
  "stage": "main",
  "timestamp": "2025-02-13T05:01:12.552485Z",
  "message": "context: environment='development' source='ai-gateway-python' realm='self-managed' instance_id='7f79d364-f4bb-4b96-9d9a-76d442c225e8' host_name='gdk.test' instance_version='17.9.0' global_user_id='+nX6PXalgNf3sEoS6tYAyV1uZzoSNUq1Y6NWOcfnbTc=' context_generated_at='2025-02-13T14:01:12.552414' extra={} is_gitlab_team_member=False feature_enabled_by_namespace_ids=[] project_id=None namespace_id=None plan=None correlation_id='01JKYTX8Q36HF379V7346ZD3BR' feature_enablement_type='add_on' client_name='ghi' client_version='def' client_type='abc' interface='jkl'"
}

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by Shinya Maeda

Merge request reports

Loading