Log all AI Gateway responses related to Amazon Q
What does this MR do and why?
When the Amazon Q work was upstreamed, we dropped the use of
Gitlab::Llm::AiGateway::Client#complete in favor of direct HTTPS
POST requests. However, this dropped the logging that came with that
method.
Re-add this logging so we can track all responses from the AI Gateway.
All messages go to llm.log.
References
Relates to #510045 (closed)
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.
How to set up and validate locally
- Set up Amazon Q on your instance: https://gitlab.com/gitlab-com/ops-sub-department/aws-gitlab-ai-integration/integration-motion-planning/-/wikis/integration-docs
- Attempt the onboarding step or any
/qquick action. - Check
/var/log/gitlab/gitlab-rails/llm.log.
Sample error
{
"severity":"ERROR",
"time":"2024-12-27T05:33:08.119Z",
"correlation_id":"01JG39NA4WJ6XQJJ9X51NFWTZK",
"meta.caller_id":"Admin::Ai::AmazonQSettingsController#create",
"meta.feature_category":"ai_abstraction_layer",
"meta.organization_id":1,
"meta.remote_ip":"REDACTED",
"meta.user":"root",
"meta.user_id":1,
"meta.client_id":"user/1",
"status":500,
"body":"AWS Error: An error occurred (AccessDenied) when calling the AssumeRoleWithWebIdentity operation: Not authorized to perform sts:AssumeRoleWithWebIdentity",
"message":"Error response from AI Gateway",
"class":"Gitlab::Llm::QAi::Client",
"ai_event_name":"error_response_received",
"ai_component":"abstraction_layer"
}
Sample success
{
"severity":"INFO",
"time":"2024-12-27T05:33:35.475Z",
"correlation_id":"01JG39P4XE4B6WW1JH8Y0MXX7P",
"meta.caller_id":"Admin::Ai::AmazonQSettingsController#create",
"meta.feature_category":"ai_abstraction_layer",
"meta.organization_id":1,
"meta.remote_ip":"REDACTED",
"meta.user":"root",
"meta.user_id":1,
"meta.client_id":"user/1",
"message":"Received successful response from AI Gateway",
"class":"Gitlab::Llm::QAi::Client",
"ai_event_name":"response_received",
"ai_component":"abstraction_layer"
}
Note that I noticed llm.log has a lot of No access to Duo Chat messages: #510920 (closed)
Edited by Stan Hu