Metrics Reports
- Tier: Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
GitLab provides a lot of great reporting tools for things like merge requests - Unit test reports, code quality, and performance tests. While JUnit is a great open framework for tests that “pass” or “fail”, it is also important to see other types of metrics from a given change.
You can configure your job to use custom Metrics Reports, and GitLab displays a report on the merge request so that it’s easier and faster to identify changes without having to check the entire log.
Use cases
Consider the following examples of data that can use Metrics Reports:
- Memory usage
- Load testing results
- Code complexity
- Code coverage stats
How it works
Metrics for a branch are read from the latest metrics report artifact (default filename: metrics.txt
) as string values.
For an MR, the values of these metrics from the feature branch are compared to the values from the target branch. Then they are displayed in the MR widget in this order:
- Existing metrics with changed values.
- Metrics that have been added by the MR. Marked with a New badge.
- Metrics that have been removed by the MR. Marked with a Removed badge.
- Existing metrics with unchanged values.
How to set it up
Add a job that creates a metrics report (default filename: metrics.txt
). The file should conform to the OpenMetrics format.
For example:
metrics:
script:
- echo 'metric_name metric_value' > metrics.txt
artifacts:
reports:
metrics: metrics.txt
Advanced Example
An advanced example of an OpenMetrics text file (from the Prometheus documentation) renders in the merge request widget as:
Troubleshooting
Metrics reports did not change
You can see Metrics reports did not change
when trying to view metrics reports in merge requests. Reasons for this are:
- The target branch for the merge request doesn’t have a baseline metrics report for comparison.
- You don’t have a paid subscription.
There is an issue open to improve this message.
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support