kibana/packages/kbn-ci-stats-reporter
Kibana Machine 11d3d5b8ca
[8.3] [ci-stats] ship buildkiteJobId with metrics and support backfilling (#137123) (#137143)
* [ci-stats] ship buildkiteJobId with metrics and support backfilling (#137123)

(cherry picked from commit 0154f75445)

* [CI] Auto-commit changed files from 'yarn kbn run build -i @kbn/pm'

Co-authored-by: Spencer <spencer@elastic.co>
2022-07-25 21:45:07 -07:00
..
src [8.3] [ci-stats] ship buildkiteJobId with metrics and support backfilling (#137123) (#137143) 2022-07-25 21:45:07 -07:00
BUILD.bazel break out parts of @kbn/dev-utils (#130509) 2022-04-19 12:24:58 -05:00
package.json break out parts of @kbn/dev-utils (#130509) 2022-04-19 12:24:58 -05:00
README.md break out parts of @kbn/dev-utils (#130509) 2022-04-19 12:24:58 -05:00
tsconfig.json break out parts of @kbn/dev-utils (#130509) 2022-04-19 12:24:58 -05:00

Kibana CI Stats reporter

We're working on building a new service, the Kibana CI Stats service, which will collect information about CI runs and metrics produced while testing Kibana, and then provide tools for reporting on those metrics in specific PRs and overall as a way to spot trends.

CiStatsReporter

This class integrates with the ciStats.trackBuild {} Jenkins Pipeline function, consuming the KIBANA_CI_STATS_CONFIG variable produced by that wrapper, and then allowing test code to report stats to the service.

To create an instance of the reporter, import the class and call CiStatsReporter.fromEnv(log) (passing it a tooling log).

CiStatsReporter#metrics(metrics: Metric[])

Use this method to record metrics in the Kibana CI Stats service.

interface Metric {
  group: string,
  id: string,
  value: number,
  // optional limit, values which exceed the limit will fail PRs
  limit?: number
  // optional path, relative to the root of the repo, where config values
  // are defined. Will be linked to in PRs which have overages.
  limitConfigPath?: string
}

Example:

import { CiStatsReporter, ToolingLog } from '@kbn/dev-utils';

const log = new ToolingLog(...);
const reporter = CiStatsReporter.fromEnv(log)
reporter.metrics([
  {
    group: 'Build size',
    id: specificBuildName,
    value: sizeOfBuild
  }
])