Skip to content

Ensure same Correlation ID is set in GitLab-Rails and AI Gateway

Shinya Maeda requested to merge fix-correlation-id-from-gitlab-rails into main

What does this merge request do and why?

This MR fixes Ensure the same Correlation ID is set in GitLab... (gitlab-org/gitlab#432375 - closed).

Currently, AI Gateway trashes the Correlation ID passed from GitLab-Rails because the ID is considered as invalid by the default validator. It should be UUID formated, but LabKit has different standard.

This MR skips the validation so that the passed Correlation ID is recorded in the AI Gateway log.

How to set up and validate locally

Request:

curl -X 'POST' \
  'http://0.0.0.0:5052/v2/code/generations' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'X-Request-ID: 12345' \
  -d '{
  "project_path": "string",
  "project_id": 0,
  "current_file": {
    "file_name": "string",
    "language_identifier": "string",
    "content_above_cursor": "string",
    "content_below_cursor": "string"
  },
  "model_provider": "anthropic",
  "telemetry": [],
  "stream": false,
  "prompt_version": 1
}'

Log

{"url": "http://0.0.0.0:5052/v2/code/generations", "path": "/v2/code/generations", "status_code": 200, "method": "POST", "correlation_id": "12345", "http_version": "1.1", "client_ip": "127.0.0.1", "client_port": 56184, "duration_s": 11.558627659000194, "cpu_s": 0.07252226399999984, "user_agent": "curl/8.4.0", "gitlab_instance_id": null, "gitlab_global_user_id": null, "gitlab_host_name": null, "gitlab_saas_namespace_ids": null, "gitlab_realm": null, "model_engine": "anthropic", "model_name": "claude-2.0", "prompt_length": 14, "prompt_length_stripped": 12, "inference_duration_s": 11.518218517001515, "lang": "", "editor_lang": "string", "model_output_length": 570, "model_output_length_stripped": 503, "model_output_score": 100000, "blocked": false, "logger": "api.access", "level": "info", "type": "mlops", "stage": "main", "timestamp": "2023-12-04T07:09:07.593821Z", "message": "127.0.0.1:56184 - \"POST /v2/code/generations HTTP/1.1\" 200"}

Merge request checklist

  • Tests added for new functionality. If not, please raise an issue to follow up.
  • Documentation added/updated, if needed.
Edited by Shinya Maeda

Merge request reports