Skip to content

Feature Request: Add OpenMetrics Exporter for GitLab CI Metrics Integration #2800

@DefinitelyADev

Description

@DefinitelyADev

Hi BenchmarkDotNet team,

I'd like to propose and contribute a new OpenMetrics exporter to BenchmarkDotNet. This would allow users to generate performance benchmark output in the OpenMetrics format, which is compatible with GitLab's built-in Metrics Reports feature.

Motivation

GitLab supports ingesting metrics in the OpenMetrics format via a metrics.txt artifact. This opens the door for integrating performance benchmarks directly into CI pipelines, making performance regressions first-class citizens of the CI/CD process. BenchmarkDotNet already supports various exporters (CSV, Markdown, HTML, etc.), but not yet OpenMetrics.

Adding an OpenMetricsExporter would allow:

  • Comparing benchmark results between commits/MRs in GitLab pipelines
  • Alerting on performance regressions directly from the GitLab UI
  • Seamless integration with DevOps workflows that rely on GitLab CI

Proposed Scope

  • A new OpenMetricsExporter implementation
  • Support for writing metrics.txt files in the OpenMetrics format
  • Mapping relevant benchmark measurements (e.g., mean, error, stdev, ops/sec) to OpenMetrics-compatible metric types (e.g., gauge)
  • Optional: labels for benchmark class/method/config to support filtering and grouping

Example output (simplified)

# TYPE benchmark_duration_seconds gauge
benchmark_duration_seconds{benchmark="MyBenchmark.MethodA",job="Default"} 0.000123

# TYPE benchmark_ops_per_second gauge
benchmark_ops_per_second{benchmark="MyBenchmark.MethodA",job="Default"} 8120.0

Benefits

  • Enables performance regression detection as part of the CI process
  • Aligns with modern DevOps practices
  • Bridges BenchmarkDotNet with GitLab-native tooling

I'm happy to contribute the implementation and open a PR if the maintainers agree with the direction.

Thanks for your amazing work on this project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions