@c2l2c/backstage-plugin-dora-metrics

中文文档
0.5.0发布于 2026/08/21Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 4649

A Backstage frontend plugin that displays DORA metrics (Deployment Frequency, Lead Time, Change Failure Rate, MTTR) for catalog entities via the GitHub API.

原始使用文档
文档目录17 节
  1. How this differs from org-level DORA scorecards
  2. Screenshots/Videos
  3. 1. DORA metrics dashboard
  4. 2. Deployment frquency exapnded view
  5. 3. LTFC expanded view
  6. 4. CFR expanded view
  7. 5. MTTR expanded view
  8. Requirements
  9. Installation
  10. Register the plugin
  11. Configuration
  12. Branch and label patterns
  13. Environment constraints
  14. Per-repo overrides via catalog annotations
  15. Example configs
  16. How it works
  17. License

@c2l2c/backstage-plugin-dora-metrics

CI Publish npm

A Backstage frontend plugin that surfaces DORA metrics per catalog entity — scoped to the specific service you're viewing, not your whole org.

For each catalog service annotated with a GitHub repo, this plugin adds a DORA Metrics tab that computes all four key metrics directly from GitHub PRs via OAuth — no extra backend or data pipeline required:

  • Deployment Frequency — how often PRs are merged to the target branch
  • Lead Time for Changes — average time from PR open to merge
  • Change Failure Rate — percentage of deployments that were hotfixes (production only)
  • MTTR — mean time to recover, measured as average hotfix PR duration (production only)
  • Hotfixes to Production - number of hotfixes deployed to production in the given time period (production only)

Ratings are classified as Elite / High / Medium / Low per DORA research benchmarks.

How this differs from org-level DORA scorecards

Org-level DORA plugins aggregate metrics across all repositories in your GitHub org. This plugin instead scopes metrics to a single catalog entity — useful when you want to track DORA health at the service level, compare environments (e.g. production vs staging), or drill into which specific PRs are driving your lead time or failure rate. It also requires no backend: all data is fetched client-side using the user's existing GitHub OAuth session.


Screenshots/Videos

1. DORA metrics dashboard

Screenshot

2. Deployment frquency exapnded view

Screenshot

3. LTFC expanded view

Screenshot

4. CFR expanded view

Screenshot

5. MTTR expanded view

Screenshot

Requirements

  • Backstage v1.35+ (new frontend system)
  • GitHub OAuth configured in your Backstage instance (the plugin uses githubAuthApi to call the GitHub REST API)
  • Catalog entities annotated with github.com/project-slug: org/repo

Installation

# In your Backstage app workspace
yarn workspace app add @c2l2c/backstage-plugin-dora-metrics

Register the plugin

In packages/app/src/App.tsx:

import doraMetricsPlugin from '@c2l2c/backstage-plugin-dora-metrics/alpha';

// Add to your app's plugins array
const app = createApp({
  plugins: [doraMetricsPlugin],
  // ...
});

Configuration

Add to your app-config.yaml:

app:
  doraMetrics:
    # Lookback window in days (default: 30)
    collection:
      initialDays: 30

    # Optional: base URL of the GitHub instance (default: https://github.com).
    # Set this for GitHub Enterprise. The REST API base URL is derived automatically:
    #   github.com        → https://api.github.com
    #   *.ghe.com (Cloud) → https://api.<host>   (e.g. https://api.va.ghe.com)
    #   other (GHE Server)→ https://<host>/api/v3
    githubUrl: https://github.com

    # Define the environments / branches to track.
    # Exactly ONE environment may set isProduction: true.
    environments:
      - name: Production
        branch: main             # single branch name
        isProduction: true
        label: hotfix            # PR label for production failures (used for CFR/MTTR)
      - name: Staging
        branch: staging
        isProduction: false
      - name: Any main
        # Comma-separated list — PRs merged to any of these branches are included
        branch: "main,master"
        isProduction: false
      - name: Release branches
        # JavaScript regex — resolved against the repo's actual branch list at query time
        branch: "^release/.*"
        isProduction: false

    # Optional: override DORA benchmark targets
    targets:
      deploymentFrequency: 1   # deploys per day (Elite ≥ 1)
      leadTime: 24             # hours (Elite ≤ 24h)
      changeFailureRate: 5     # % (Elite ≤ 5%)
      mttr: 1                  # hours (Elite ≤ 1h)

    # Optional: enable mock data for local development (skips GitHub API calls)
    debug: false

Branch and label patterns

Both the branch and label fields accept the same three formats:

FormatExampleBehaviour
Single namemain / hotfixExact match
Comma-separatedmain,master / hotfix,fix,bugMatches any name in the list
JavaScript regex^release/.* / ^hotfixRegex test against each value

A string is treated as a regex if it contains any of these characters: | ^ $ [ ] ( ) { } ? + * \

For branch: when multiple branches match, PRs are fetched from all of them and deduplicated by PR number. Regex patterns are resolved against the repo's live branch list via the GitHub Branches API at query time.

For label: a PR is classified as a hotfix if any of its GitHub labels match the pattern.

Environment constraints

  • You may define any number of environments.
  • Exactly one environment may have isProduction: true. The plugin throws a configuration error at startup if this constraint is violated.
  • Change Failure Rate, MTTR, and Hotfixes to Production are only calculated for the production environment.

Per-repo overrides via catalog annotations

You can override environments and targets on a per-service basis in catalog-info.yaml without changing the global config:

metadata:
  annotations:
    github.com/project-slug: my-org/my-repo

    # Override the environments list for this repo only (JSON)
    dora-metrics/environments: |
      [
        { "name": "Production", "branch": "main", "isProduction": true, "label": "hotfix" },
        { "name": "Staging",    "branch": "staging", "isProduction": false }
      ]

    # Override DORA targets for this repo only (JSON, partial overrides supported)
    dora-metrics/targets: |
      { "deploymentFrequency": 2, "leadTime": 48 }

Annotation values are parsed as JSON. Partial targets overrides are merged with the global targets — only the keys you specify are replaced.

Example configs

Ready-to-use example configs are in the examples/ directory:

FileDescription
app-config.regex-branch.yamlProduction tracked with a regex branch pattern (^release/.*) and a comma-separated label pattern
app-config.multi-branch.yamlProduction tracked across main,master; staging across develop,dev; hotfix label as regex
catalog-info.yamlPer-repo environment and target overrides via catalog-info.yaml annotations

How it works

The plugin reads the github.com/project-slug annotation from the catalog entity and calls the GitHub REST API (authenticated via the user's GitHub OAuth session) to fetch merged pull requests within the configured time window.

It calculates:

  • Deployment Frequency: merged PRs per day to the target branch
  • Lead Time: time from PR creation to merge
  • CFR: percentage of PRs labelled as hotfixes (production environments only)
  • MTTR: average time hotfix PRs were open (production environments only)
  • Hotfixes to Production - number of hotfixes deployed to production in the given time period (production environments only)

License

Apache-2.0

版本与发布记录

@c2l2c/backstage-plugin-dora-metrics 共发布 9 个版本,首次发布于 2026/03/18;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.5.0latest2026/08/212 个月前
0.4.32026/06/284 个月前
0.4.22026/06/284 个月前
0.4.12026/06/284 个月前
0.4.02026/06/284 个月前
0.3.32026/04/256 个月前

关于 @c2l2c/backstage-plugin-dora-metrics 的常见问题

@c2l2c/backstage-plugin-dora-metrics 是什么?

A Backstage frontend plugin that displays DORA metrics (Deployment Frequency, Lead Time, Change Failure Rate, MTTR) for catalog entities via the GitHub API.

如何安装 @c2l2c/backstage-plugin-dora-metrics?

在项目目录运行 npm install @c2l2c/backstage-plugin-dora-metrics,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^17.0.0 || ^18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@c2l2c/backstage-plugin-dora-metrics 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@c2l2c/backstage-plugin-dora-metrics 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@c2l2c/backstage-plugin-dora-metrics 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@c2l2c/backstage-plugin-dora-metrics 可以商用吗?

@c2l2c/backstage-plugin-dora-metrics 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@c2l2c/backstage-plugin-dora-metrics 的下载量有多少?

根据 npm 官方下载统计,@c2l2c/backstage-plugin-dora-metrics 在 2026/10/09 – 2026/11/07 这 30 天内被下载 4,649 次,日均约 155 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@c2l2c/backstage-plugin-dora-metrics 还在维护吗?

最新版本 0.5.0 发布于 2026/08/21(2 个月前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/03/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。