DORA Metrics Configuration#
Overview#
DevLake computes the four DORA metrics (Deployment Frequency, Lead Time for Changes, Change Failure Rate, Mean Time to Restore) by combining data from three plugins: GitHub (or another CI/CD source), refdiff, and dora. Configuration happens primarily on the GithubScopeConfig for individual repos, then flows through a multi-stage pipeline.
GitHub Scope Config: Key DORA Fields#
The GithubScopeConfig (stored in _tool_github_scope_configs) holds three regex fields that drive deployment classification:
| Field | Purpose |
|---|---|
DeploymentPattern | Regex matched against workflow/job name. If it matches, the run/job is classified as type DEPLOYMENT. |
ProductionPattern | Regex matched against workflow/job name or branch name (HeadBranch for runs). If omitted (empty), all deployments default to PRODUCTION. If set, only matching ones get the PRODUCTION environment label. |
EnvNamePattern | Regex to extract a custom environment name from the workflow/job name. |
These are compiled into a RegexEnricher during PrepareTaskData in impl.go.
The scope config also holds a Refdiff field β a free-form JSON map passed directly to the refdiff plugin (see below).
How Patterns Are Applied: CICD Extractors#
Both workflow-run and job extractors consume the RegexEnricher from GithubTaskData:
- Workflow runs (
ExtractRuns):Typeis set viaReturnNameIfMatched(DEPLOYMENT, run.Name);EnvironmentviaReturnNameIfOmittedOrMatched(PRODUCTION, run.Name, run.HeadBranch). - Jobs (
ExtractJobs): same pattern, matching againstjob.Nameonly.
ReturnNameIfMatched returns the label name if the regex matches, or "" otherwise. ReturnNameIfOmittedOrMatched returns the label unconditionally when the regex is absent β meaning an empty ProductionPattern tags every deployment as production.
Refdiff Configuration#
The Refdiff JSON map in GithubScopeConfig is passed as-is to the refdiff plugin in a separate pipeline stage added after the GitHub collection stage . A repoId key is injected automatically using the domain-layer ID for the repo.
Refdiff's RefdiffOptions recognises:
| Field | Type | Purpose |
|---|---|---|
tagsPattern | string | Regex to select tags from the refs table |
tagsLimit | int | Max number of matching tags to use |
tagsOrder | string | Sort order: alphabetically, reverse alphabetically, semver, reverse semver |
pairs | []RefPair | Explicit {NewRef, OldRef} pairs to diff |
CalculateTagPattern queries all refs, applies the regex, sorts, and trims to tagsLimit. CalculateCommitPairs converts both explicit pairs and tag-derived pairs into commit SHAs, deduplicating as it goes.
Refdiff populates the commits_diffs table, which the DORA plugin reads to trace which commits reached production.
DORA Plugin Pipeline#
The DORA plugin is a project-scoped metric plugin that orchestrates a three-stage pipeline :
Stage 1 β runs three subtasks :
generateDeployments: buildscicd_deploymentsfrom CI/CD pipelines classified as typeDEPLOYMENT.generateDeploymentCommits: createscicd_deployment_commitslinking commits to deployments.enrichPrevSuccessDeploymentCommits: links each deployment commit to the previous successful one (needed to bound the commit diff range).
Stage 2 β calls the refdiff plugin's calculateDeploymentCommitsDiff to fill commits_diffs with all commits between consecutive deployments.
Stage 3 β metric calculation:
calculateChangeLeadTime: joinscommits_diffswith pull requests to sum coding time + pickup time + review time + deploy time.ConvertIssuesToIncidentsandConnectIncidentToDeployment: link incidents to the nearest prior production deployment (Change Failure Rate / MTTR).
Change Lead Time decomposition#
The metric is calculated by calculateChangeLeadTime as:
| Component | Measured as |
|---|---|
| Coding time | First commit authored date β PR creation |
| Pickup time | PR creation β first review |
| Review time | First review β PR merge |
| Deploy time | PR merge β deployment finish |
The deploy-time lookup filters for PRODUCTION environment and successful result, joined via commits_diffs .
Configuration Checklist#
To enable full DORA metrics for a GitHub repo:
- Set
DeploymentPatternin the repo's Scope Config to match workflow or job names that represent deployments (e.g.,deploy,release). - Set
ProductionPatternif you have non-production environments to exclude (leave empty to treat all deployments as production). - Set
RefdiffJSON in the Scope Config withtagsPattern/tagsLimit/tagsOrderor explicitpairsto enable commit-diff calculation between releases. - Ensure the CICD domain type is included in the repo's Scope Config entities so GitHub Actions data is collected.
- Associate the repo with a DevLake Project (
ProjectNamein DORA's options), ascalculateChangeLeadTimefilters PRs by project.
Key Source Files#
| File | Role |
|---|---|
github/models/scope_config.go | GithubScopeConfig struct β all DORA-relevant fields |
github/impl/impl.go | Compiles regex patterns into RegexEnricher at task start |
github/tasks/cicd_run_extractor.go | Classifies workflow runs as deployments/environments |
github/tasks/cicd_job_extractor.go | Classifies jobs as deployments/environments |
github/api/blueprint_v200.go | Injects refdiff as a follow-on pipeline stage |
refdiff/models/refdiff_options.go | RefdiffOptions struct β tag pattern and pair config |
refdiff/tasks/refdiff_task_data.go | Tag pattern matching and commit pair calculation |
dora/impl/impl.go | Three-stage DORA pipeline definition |
dora/tasks/change_lead_time_calculator.go | Change lead time calculation logic |
helpers/pluginhelper/api/enrich_with_regex.go | RegexEnricher utility used by all CICD extractors |