doc/solutions/components/duo_adoption_metrics.md
{{< details >}}
{{< /details >}}
This project provides end-to-end GitLab Duo usage analytics, combining:
You can control which analytics pipelines run by setting these Project CI/CD Variables:
| Variable | Duo Setup | Description |
|---|---|---|
ENABLE_DUO_METRICS | "true" | Enable/disable Duo AI metrics pipeline. |
ENABLE_PROJECT_METRICS | "false" | Disable traditional project-centric metrics when you only care about Duo adoption. |
DUO_TOKEN | TOKEN VALUE | Personal Access Token with read_api and ai_features permissions for Duo usage collection. |
GROUP_PATH | example_group | Top-level group or subgroup path to collect Duo metrics for. |
Steps for Quick Start
When Duo metrics are enabled, Pages deployment happens automatically after the Duo pipeline completes:
https://your-username.gitlab.io/project-name/duo-metrics/.https://your-username.gitlab.io/project-name/, with links to available dashboards.The landing page auto-detects which dashboards are present and shows Duo-related links when ENABLE_DUO_METRICS="true".
For local testing of Duo analytics (without CI):
poetry install at the repo root)..env or shell session:
DUO_TOKENGROUP_PATHpython ai_raw_data_collection.py
public/ or docs/ folder (depending on your setup), or run the dashboard locally as described in the solution component project documentation.The Duo Analytics Dashboard focuses on GitLab Duo adoption and AI usage patterns, including:
These metrics are derived entirely from Duo-related signals; traditional project metrics are not required to use this dashboard.
Duo adoption metrics are created by a CI-driven data collection pipeline that relies on:
ai_raw_data_collection.pygitlab_graphql_apiai_raw_data_collection.pyThe script ai_raw_data_collection.py is responsible for:
GROUP_PATH, DUO_TOKEN, and pipeline configuration).It acts as a generic entry point for collecting raw Duo usage data, so you can:
All Duo-related GraphQL logic is encapsulated in the gitlab_graphql_api Python package, particularly under:
gitlab_graphql_api > collectionsKey ideas:
collections module provides higher-level abstractions (such as “project collections” or “user collections”) that expose methods for retrieving structured data. Duo collectors use these to:
GROUP_PATH.The Duo collectors import these collection classes and define the specific queries they need (for example, fetching counts of AI code suggestions, chat usage events, or user-level adoption statistics).
Note: The GraphQL schema and field names for Duo usage are documented alongside the collection classes in
gitlab_graphql_api > collections. Use those docs when extending or customizing the data collected for Duo metrics.
While the pipeline can be customized, a typical Duo-only setup requires:
ENABLE_DUO_METRICS="true".ENABLE_PROJECT_METRICS="false".ai_raw_data_collection.py:| Variable | Description | Example |
|---|---|---|
DUO_TOKEN | Token with read_api + ai_features, used for Duo GraphQL queries. | glpat-xxxx |
GROUP_PATH | Group or subgroup whose Duo usage should be measured. | "gitlab-org/your-group" |
DUO_METRICS_OUTPUT_DIR | Optional output directory for raw Duo usage data. | "duo-metrics/raw" |
With these set, the CI job that runs ai_raw_data_collection.py will:
gitlab_graphql_api collections to query Duo usage data for the specified group.To add or refine Duo adoption metrics:
gitlab_graphql_api > collections abstractions.ai_raw_data_collection.py (or control it via environment variables).Because the GraphQL access and pagination logic are encapsulated inside gitlab_graphql_api, extending Duo metrics typically means:
gitlab_graphql_api package and collections module (for Duo GraphQL usage patterns)