A Rust-based collector for GitLab engineering metrics and GitHub Copilot usage metrics. Imports projects, merge requests, and Copilot user metrics into PostgreSQL with optional AI-powered summarization for merge requests.
- GitLab REST and GraphQL API integration
- GitHub Copilot org user usage metrics ingestion via daily report downloads
- Incremental updates with resumable imports
- Optional AI enhancement for merge requests
- Concurrent processing of multiple groups
- Rust 1.73+, PostgreSQL 18+, Docker (optional)
- GitLab API token
- GitHub token with Copilot metrics access when running the Copilot collector
This repository now produces 2 Cargo binaries:
engineering-metrics-data-collector- the GitLab collectorcopilot_metrics_collector- the GitHub Copilot metrics collector
# Build both binaries
cargo build --release
# Build only the GitLab collector
cargo build --release --bin engineering-metrics-data-collector
# Build only the Copilot metrics collector
cargo build --release --bin copilot_metrics_collectorThe compiled executables are written to:
target/release/engineering-metrics-data-collector
target/release/copilot_metrics_collectorThe current Dockerfile still packages only the default GitLab collector binary:
docker build -t engineering-metrics-data-collector .Create .env file:
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
GITLAB_REST_ENDPOINT=https://gitlab.com/api/v4
GITLAB_GRAPHQL_ENDPOINT=https://gitlab.com/api/graphql
GITLAB_API_TOKEN=your_token
GITLAB_FULL_PATH_GROUP_LIST=group1,group2
# Optional GitHub Copilot collector configuration
# COPILOT_API_KEY — copilot, read:enterprise, read:org, read:user
GITHUB_API_TOKEN=your_github_token
GITHUB_API_ENDPOINT=https://api.github.com
GITHUB_API_VERSION=2026-03-10
GITHUB_COPILOT_ORG_LIST=org1,org2
COPILOT_REPORT_LAG_DAYS=2
COPILOT_INITIAL_INGESTION_DATE=2026-01-01T00:00:00Z
# Optional AI configuration
AI_BASE_URL=https://api.openai.com/v1
AI_MODEL=gpt-4
AI_API_KEY=your_key
AI_MAX_CONTEXT_CHARS=8000
# Optional settings
UPSERT_MERGE_REQUESTS=true
INITIAL_INGESTION_DATE=2024-01-01T00:00:00Z# Run the GitLab collector
cargo run --release --bin engineering-metrics-data-collector
# Or run the current Docker image, which starts the GitLab collector binary
docker run --env-file .env engineering-metrics-data-collectorcargo run --release --bin copilot_metrics_collectorThis binary fetches daily org-level user usage reports from:
GET /orgs/{org}/copilot/metrics/reports/users-1-day?day=YYYY-MM-DDThe Copilot flow runs independently from the GitLab collector and keeps its own successful-run watermark and resumable import progress.
Tables in engineering_metrics schema:
projects- GitLab project metadatamerge_requests- MR data with AI enhancement fieldscollector_runs- Tracks successful runs for incremental updatesimport_progress- Enables resumable importscopilot_user_daily_metrics- Copilot per-user per-day fact tablecopilot_user_daily_*- Copilot feature, IDE, language, and model breakdown tablescopilot_collector_runs- Tracks successful Copilot report ingestion by org
cargo fmt # Format code
cargo check # Check compilation
cargo clippy --all-targets # Lint
cargo test # Run testsGuidelines: No .unwrap(), use Result and ?. Prefer &str over String. Keep code clippy-clean.
Integration tests require Docker. Tests use wiremock for API mocking.
# Start local PostgreSQL
docker run --name local-postgres -p 5433:5432 \
-e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres -d postgres:18
# Cleanup
docker rm -f local-postgresSupported methods:
# Personal Access Token
curl --header "PRIVATE-TOKEN: XXX" "https://gitlab.com/api/v4/projects/{id}"
# OAuth2 Bearer Token
curl --header "Authorization: Bearer XXX" "https://gitlab.com/api/v4/projects/{id}"