-
Notifications
You must be signed in to change notification settings - Fork 115
feat(scorecard): introduce scorecard dora plugin #4235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dzemanov
wants to merge
10
commits into
redhat-developer:main
Choose a base branch
from
dzemanov:scorecard/scorecard-dora
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
49cfeb3
Scorecard DORA GitHub (#6)
dzemanov f23dd11
feat(scorecard): Scorecard DORA Jira (#7)
dzemanov cf83720
feat(scorecard-dora): Timeseries API (#10)
djanickova 5859396
Migrate dora plugin to bs 1.52.0
dzemanov 7bcdda0
Fix timeseries
dzemanov d0d5d44
Include change of plugins renamed to metricProviders
dzemanov e7c248f
Move incident issue type under dora collector input
dzemanov 3c5518f
Update api reports
dzemanov fbdaafd
Add changeset
dzemanov 1f75596
Update changeset and remove node
dzemanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-dora': minor | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-github': minor | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-jira': minor | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard-backend': minor | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard-common': minor | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard': minor | ||
| --- | ||
|
|
||
| Add DORA metrics and a collectors framework for composing datasource data into metrics. | ||
|
|
||
| - New `@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-dora` with Deployment Frequency, Median Lead Time for Changes, Mean Time to Restore, and Change Failure Rate | ||
| - New data collectors used by DORA: GitHub deployments, deployment workflow runs, and deployment pull requests; Jira incidents | ||
| - Metric time-series API `/metrics/catalog/:kind/:namespace/:name/time-series` | ||
| - Adds `defaultVisualization` to Metric metadata for sparkline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
workspaces/scorecard/examples/components/dora-scorecard.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| # Component with DORA Scorecard | ||
| apiVersion: backstage.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: dora-scorecard | ||
| annotations: | ||
| github.com/project-slug: dzemanov/test-scorecard-github-dora | ||
| backstage.io/source-location: url:https://github.com/dzemanov/test-scorecard-github-dora | ||
| scorecard.io/dora: 'true' | ||
| jira/incident-project-key: RSPT | ||
| spec: | ||
| type: service | ||
| owner: group:development/guests | ||
| lifecycle: experimental | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
workspaces/scorecard/plugins/scorecard-backend-module-dora/.eslintrc.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); |
163 changes: 163 additions & 0 deletions
163
workspaces/scorecard/plugins/scorecard-backend-module-dora/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| # Scorecard Backend Module for DORA | ||
|
|
||
| This is an extension module to the `backstage-plugin-scorecard-backend` plugin that provides DORA (DevOps Research and Assessment) metrics – key indicators of software delivery performance. | ||
|
|
||
| DORA module uses [**collectors**](../scorecard-backend/docs/collectors.md) – reusable components designed to gather data from various datasources, such as Jira or GitHub. You can create your custom data collector to tailor data collection for DORA metrics calculation for your specific setup. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Before installing this module, ensure that the Scorecard backend plugin is integrated into your Backstage instance. Follow the [Scorecard backend plugin README](../scorecard-backend/README.md) for setup instructions. | ||
|
|
||
| If you use built-in collectors from GitHub and Jira modules, install the corresponding backend modules so those collectors are registered: | ||
|
|
||
| - `@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-github` | ||
| - `@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-jira` | ||
|
|
||
| ## Installation | ||
|
|
||
| To install this backend module: | ||
|
|
||
| ```bash | ||
| # From your root directory | ||
| yarn workspace backend add @red-hat-developer-hub/backstage-plugin-scorecard-backend-module-dora | ||
| ``` | ||
|
|
||
| ```ts | ||
| // packages/backend/src/index.ts | ||
| import { createBackend } from '@backstage/backend-defaults'; | ||
|
|
||
| const backend = createBackend(); | ||
|
|
||
| backend.add( | ||
| import('@red-hat-developer-hub/backstage-plugin-scorecard-backend'), | ||
| ); | ||
|
|
||
| backend.add( | ||
| import( | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-dora' | ||
| ), | ||
| ); | ||
|
|
||
| backend.start(); | ||
| ``` | ||
|
|
||
| ### Entity annotations | ||
|
|
||
| DORA metric providers run only for entities that include: | ||
|
|
||
| ```yaml | ||
| metadata: | ||
| annotations: | ||
| scorecard.io/dora: 'true' | ||
| ``` | ||
|
|
||
| ## Available Metrics | ||
|
|
||
| | Metric ID | Provider ID | Default thresholds | Details | | ||
| | ------------------------------- | ------------------------------- | ------------------------------------------------------ | --------------------------------------------------------------------------------- | | ||
| | `dora.deploymentFrequency` | `dora.deploymentFrequency` | elite `>=7`, medium `1-7`, low `<1` (deployments/week) | [deployment-frequency.md](./docs/metrics/deployment-frequency.md) | | ||
| | `dora.medianLeadTimeForChanges` | `dora.medianLeadTimeForChanges` | elite `<24`, medium `24-168`, low `>168` (hours) | [median-lead-time-for-changes.md](./docs/metrics/median-lead-time-for-changes.md) | | ||
| | `dora.meanTimeToRestore` | `dora.meanTimeToRestore` | elite `<1`, medium `1-24`, low `>24` (hours) | [mean-time-to-restore.md](./docs/metrics/mean-time-to-restore.md) | | ||
| | `dora.changeFailureRate` | `dora.changeFailureRate` | elite `<5`, medium `5-15`, low `>15` (%) | [change-failure-rate.md](./docs/metrics/change-failure-rate.md) | | ||
|
|
||
| ## Threshold customization | ||
|
|
||
| Thresholds map metric values to visual categories. DORA defaults use `elite`, `medium`, and `low` (see [Available Metrics](#available-metrics)). | ||
|
|
||
| You can customize them in two ways (highest priority first): | ||
|
|
||
| 1. **Entity annotations** — merge with existing rules (same keys only) | ||
| 2. **App configuration** — replace provider defaults for that metric | ||
|
|
||
| See [threshold configuration](../scorecard-backend/docs/thresholds.md) for details. | ||
|
|
||
| **App configuration example**: | ||
|
|
||
| ```yaml | ||
| # app-config.yaml | ||
| scorecard: | ||
| metricProviders: | ||
| dora: | ||
| deploymentFrequency: | ||
| thresholds: | ||
| rules: | ||
| - key: elite | ||
| expression: '>=5' | ||
| - key: medium | ||
| expression: '1-5' | ||
| - key: low | ||
| expression: '<1' | ||
| ``` | ||
|
|
||
| Paths follow `scorecard.metricProviders.dora.<metricProviderName>.thresholds` (update `metricProviderName` to `deploymentFrequency`, `medianLeadTimeForChanges`, `meanTimeToRestore` or `changeFailureRate`). | ||
|
|
||
| **Entity annotation example** (overrides selected keys; others keep app-config or defaults): | ||
|
|
||
| ```yaml | ||
| # catalog-info.yaml | ||
| apiVersion: backstage.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: my-service | ||
| annotations: | ||
| scorecard.io/dora: 'true' | ||
| # Format: scorecard.io/{metricId}.thresholds.rules.{key}: '{expression}' | ||
| scorecard.io/dora.deploymentFrequency.thresholds.rules.elite: '>=8' | ||
| scorecard.io/dora.deploymentFrequency.thresholds.rules.medium: '1-8' | ||
| scorecard.io/dora.changeFailureRate.thresholds.rules.elite: '<10' | ||
| scorecard.io/dora.changeFailureRate.thresholds.rules.medium: '10-20' | ||
| scorecard.io/dora.changeFailureRate.thresholds.rules.low: '>20' | ||
| spec: | ||
| type: service | ||
| lifecycle: production | ||
| owner: team-a | ||
| ``` | ||
|
|
||
| ## Use your own collectors | ||
|
|
||
| You can replace default collector IDs via `app-config.yaml` as long as your collectors implement the schema contracts expected by each metric: | ||
|
|
||
| - `dora.deploymentFrequency` [collector contracts](./docs/metrics/deployment-frequency.md#collectors) | ||
| - `dora.medianLeadTimeForChanges` [collector contracts](./docs/metrics/median-lead-time-for-changes.md#collectors) | ||
| - `dora.meanTimeToRestore` [collector contracts](./docs/metrics/mean-time-to-restore.md#collectors) | ||
| - `dora.changeFailureRate` [collector contracts](./docs/metrics/change-failure-rate.md#collectors) | ||
|
|
||
| Collector inputs are merged with provider-generated required inputs. This lets you pass extra collector-specific fields (for example `workflowName` when using a workflow-runs based collector) as long as required contract fields are still supported. | ||
|
|
||
| ```yaml | ||
| scorecard: | ||
| metricProviders: | ||
| dora: | ||
| deploymentFrequency: | ||
| options: | ||
| productionEnvironments: [production, prod] | ||
| collectors: | ||
| deployments: | ||
| id: customDatasource:deployments | ||
| input: | ||
| # merged with generated from/to window | ||
| # your collector-specific options | ||
| medianLeadTimeForChanges: | ||
| options: | ||
| productionEnvironments: [production, prod] | ||
| collectors: | ||
| deployments: | ||
| id: customDatasource:deployments | ||
| input: | ||
| # merged with generated from/to window | ||
| deploymentPullRequests: | ||
| id: customDatasource:deploymentPullRequests | ||
| input: | ||
| # merged with generated baseCommitSha/headCommitSha | ||
| ``` | ||
|
|
||
| ## Scheduling | ||
|
|
||
| DORA providers follow Scorecard scheduling settings under their metric keys: | ||
|
|
||
| - `scorecard.metricProviders.dora.deploymentFrequency.schedule` | ||
| - `scorecard.metricProviders.dora.medianLeadTimeForChanges.schedule` | ||
| - `scorecard.metricProviders.dora.meanTimeToRestore.schedule` | ||
| - `scorecard.metricProviders.dora.changeFailureRate.schedule` | ||
|
|
||
| See [providers.md](../scorecard-backend/docs/providers.md#metric-collection-scheduling) for schedule schema and defaults. |
99 changes: 99 additions & 0 deletions
99
workspaces/scorecard/plugins/scorecard-backend-module-dora/config.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /* | ||
| * Copyright Red Hat, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { SchedulerServiceTaskScheduleDefinitionConfig } from '@backstage/backend-plugin-api'; | ||
| import { | ||
| CollectorConfig, | ||
| ThresholdConfig, | ||
| } from '@red-hat-developer-hub/backstage-plugin-scorecard-common'; | ||
|
|
||
| export interface Config { | ||
| /** Configuration for scorecard dora plugin */ | ||
| scorecard?: { | ||
| metricProviders?: { | ||
| dora?: { | ||
| deploymentFrequency?: { | ||
| /** | ||
| * Provider-specific options. | ||
| */ | ||
| options?: { | ||
| /** | ||
| * Environment names treated as production (case-insensitive). | ||
| * Missing/unknown deployment environments still count as production. | ||
| * @default ['production'] | ||
| */ | ||
| productionEnvironments?: string[]; | ||
| collectors?: { | ||
| deployments?: CollectorConfig; | ||
| }; | ||
| }; | ||
| thresholds?: ThresholdConfig; | ||
| schedule?: SchedulerServiceTaskScheduleDefinitionConfig; | ||
| }; | ||
| medianLeadTimeForChanges?: { | ||
| /** | ||
| * Provider-specific options. | ||
| */ | ||
| options?: { | ||
| /** | ||
| * Environment names treated as production (case-insensitive). | ||
| * Missing/unknown deployment environments still count as production. | ||
| * @default ['production'] | ||
| */ | ||
| productionEnvironments?: string[]; | ||
| collectors?: { | ||
| deployments?: CollectorConfig; | ||
| deploymentPullRequests?: CollectorConfig; | ||
| }; | ||
| }; | ||
| thresholds?: ThresholdConfig; | ||
| schedule?: SchedulerServiceTaskScheduleDefinitionConfig; | ||
| }; | ||
| meanTimeToRestore?: { | ||
| /** | ||
| * Provider-specific options. | ||
| */ | ||
| options?: { | ||
| collectors?: { | ||
| incidents?: CollectorConfig; | ||
| }; | ||
| }; | ||
| thresholds?: ThresholdConfig; | ||
| schedule?: SchedulerServiceTaskScheduleDefinitionConfig; | ||
| }; | ||
| changeFailureRate?: { | ||
| /** | ||
| * Provider-specific options. | ||
| */ | ||
| options?: { | ||
| /** | ||
| * Environment names treated as production (case-insensitive). | ||
| * Missing/unknown deployment environments still count as production. | ||
| * @default ['production'] | ||
| */ | ||
| productionEnvironments?: string[]; | ||
| collectors?: { | ||
| deployments?: CollectorConfig; | ||
| incidents?: CollectorConfig; | ||
| }; | ||
| }; | ||
| thresholds?: ThresholdConfig; | ||
| schedule?: SchedulerServiceTaskScheduleDefinitionConfig; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update source to official rhdh repo in following PR