Loading
Record most used model in workflow session credits ingestion
What does this MR do and why?
- GitLab periodically asks the subscription portal how many credits each Duo Agent Platform workflow session used, and stores that in a ClickHouse analytics table.
- That table has a column for which model the session used, but it has always been left blank.
- This MR fills in that column with the model the session used the most, so usage can be broken down by model. Sessions with no reported model still get their credits recorded, with an empty model value.
References
- Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/592684 https://gitlab.com/gitlab-org/gitlab/-/work_items/629850
Screenshots or screen recordings
No UI changes.
How to set up and validate locally
- Make sure ClickHouse is running in GDK and enabled for analytics. In a Rails console:
Gitlab::CurrentSettings.update!(use_clickhouse_for_analytics: true) - Have at least one Duo Agent Platform workflow (
Ai::DuoWorkflows::Workflow) record in a group namespace. Note its workflow id and its root namespace id. - Run the ingestion in a Rails console:
Against a local GDK with no CustomersDot connection, stub the client response instead, or run the specs below.
Ai::DuoWorkflows::SessionCredits::IngestService.new(namespace_id: <root namespace id>, workflow_ids: [<workflow id>]).execute - Check the resulting row in ClickHouse:
Confirm
SELECT workflow_id, credits_used, model_used FROM duo_workflow_session_enrichments FINALmodel_usedholds a model name, or an empty string when the session reported none. - Run the specs:
bundle exec rspec ee/spec/services/ai/duo_workflows/session_credits/ingest_service_spec.rb ee/spec/lib/gitlab/subscription_portal/subscription_usage_client_spec.rb
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Serhii Yarynovskyi