DORA Metrics Configuration#
DevLake computes the four DORA metrics β Deployment Frequency, Lead Time for Changes, Change Failure Rate (CFR), and Mean Time to Restore (MTTR) β by combining data from three plugins: a CI/CD source (GitHub, GitLab, or Azure DevOps), refdiff, and dora. Configuration is set per-repository in the plugin's Scope Config, then flows through a multi-stage pipeline.
Scope Config: Deployment Classification Patterns#
The GithubScopeConfig (stored in _tool_github_scope_configs) holds three regex fields that classify CI/CD runs and jobs:
| Field | Matched Against | Effect |
|---|---|---|
DeploymentPattern | Workflow/job name | If matched β Type = DEPLOYMENT. Must match explicitly; unmatched runs are not deployments. |
ProductionPattern | Workflow/job name or branch (HeadBranch for runs) | If matched β Environment = PRODUCTION. Empty = all deployments are production. |
EnvNamePattern | Workflow/job name | Extracts a custom environment name string. |
The same three fields exist in GitlabScopeConfig and (without EnvNamePattern) in AzuredevopsScopeConfig.
The scope config also holds a Refdiff field (datatypes.JSONMap) passed directly to the refdiff plugin (see below).
How patterns are compiled: At task start, PrepareTaskData compiles all three patterns into a RegexEnricher. Extractors call two methods on it:
ReturnNameIfMatchedβ returns the label only when the regex matches (DeploymentPattern).ReturnNameIfOmittedOrMatchedβ returns the label unconditionally if no pattern is set (ProductionPattern).
Run vs. job-level matching: Workflow run extraction tests ProductionPattern against both run.Name and run.HeadBranch, so you can scope production to a branch (e.g., main) without renaming workflows. Job extraction tests job name only.
Refdiff Configuration#
The Refdiff JSONMap in GithubScopeConfig is injected as a separate pipeline stage after GitHub collection by blueprint_v200.go. The repoId key is auto-injected using the domain-layer repo ID.
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 | 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 resolves both explicit pairs and tag-derived pairs to commit SHAs. The output β the commits_diffs table β is the join surface the DORA plugin uses to trace which commits reached production.
DORA Plugin Pipeline#
The DORA plugin is project-scoped and orchestrates a three-stage pipeline:
Stage 1 β Deployment generation
generateDeploymentsβ buildscicd_deploymentsfrom pipelines classified asDEPLOYMENT.generateDeploymentCommitsβ createscicd_deployment_commitslinking commits to deployments.enrichPrevSuccessDeploymentCommitsβ links each deployment commit to the previous successful one (bounds the diff range for lead time).
Stage 2 β Diff calculation
- refdiff's
calculateDeploymentCommitsDifffillscommits_diffswith all commits between consecutive production deployments.
Stage 3 β Metric calculation
calculateChangeLeadTimeβ joinscommits_diffswith PRs to compute the lead time breakdown. Filters forPRODUCTIONenvironment and successful result.ConvertIssuesToIncidents+ConnectIncidentToDeploymentβ link incidents to the nearest prior production deployment for CFR/MTTR.
Change Lead Time Decomposition#
calculateChangeLeadTime breaks the metric into four segments stored in project_pr_metrics:
| Field | Measured as |
|---|---|
PrCodingTime | First commit β PR creation |
PrPickupTime | PR creation β first review |
PrReviewTime | First review β PR merge |
PrDeployTime | PR merge β deployment finish |
PrCycleTime | Total (sum of above) |
Configuration Checklist#
To enable full DORA metrics for a GitHub repo:
DeploymentPatternβ set a regex matching workflow/job names that represent deployments (e.g.,(?i)deploy|release). Required; without it, no deployments are generated.ProductionPatternβ set to filter non-production environments (e.g.,(?i)prod|main). Leave empty to treat all deployments as production.Refdiffβ add JSON withtagsPattern/tagsLimit/tagsOrderor explicitpairsto enable commit-diff calculation between releases.- CICD entities β ensure the CICD domain type is included in Scope Config entities so GitHub Actions data is collected.
- DevLake Project β associate the repo with a project (
ProjectNamein DORA options);calculateChangeLeadTimefilters PRs by project.
Key Source Files#
| File | Role |
|---|---|
github/models/scope_config.go | GithubScopeConfig struct β all DORA-relevant pattern fields |
helpers/pluginhelper/api/enrich_with_regex.go | RegexEnricher β shared pattern-matching utility |
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 β 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 |
crossdomain/project_pr_metric.go | ProjectPrMetric β per-PR lead time decomposition |