Deprecation of custom metrics?

Hi,

My plugin creates a few custom metrics and saves measures for those metrics. I have noticed that now in 8.2 there is a warning message on the admin page of custom metrics saying that “Custom metrics are deprecated and will be removed soon.”.


I also noticed that data for my custom metrics stopped showing up on the activity graph since the time I upgraded to 7.9. I’m not sure exactly in which version this stopped working because I skipped over a few minor versions and moved to 7.9 directly from 7.4.

I was hoping that I could get some answers around custom metrics because I’m not sure whether this is a bug that they no longer show up in the activity or this functionality was removed intentionally. I’m also confused around the deprecation of custom metrics because they don’t seem to be deprecated in the plugin API. The user interface says they are deprecated, but from a plugin level, you can still create them and submit measures without any warnings. If custom metrics are going away, could someone please explain to me the reasoning behind it and whether there is any replacement or similar functionality that plugin developers can use instead?

Thanks,
Michael

1 Like

Hey there.

Custom Measures (also called Manual Measures) have been deprecated and will be removed someday. They are manual, inconsistent, and typically used to collect non-quality related metrics (and we don’t want SonarQube to become a place where this data is dumped).

This is very different from measures being defined/computed by a plugin, which get updated after an analysis. No sign of those going away.

Measures provided from a plugin should still be accessible from the Activity tab of a project (switching to Custom and selecting your metric from the list). At least, it’s fine when I deploy the 7.x branch of SonarSource/sonar-custom-plugin-example. Do your measures still show up in the Measures tab?

Hi Colin, thanks for your reply.

Ok, yeah it totally makes sense to drop manual measures :+1:

Do your measures still show up in the Measures tab?

No, they no longer show up in the Measures tab.

Measures provided from a plugin should still be accessible from the Activity tab of a project (switching to Custom and selecting your metric from the list).

Yes, I can confirm that my custom measures are available in the list of custom metrics, but once I select any of them only the historical data is shown on the activity graph up until the point when I migrated from 7.4 to 7.9; no new data is shown for analysis run since then (see the screenshot below). I’ve also tried on a clean 8.2 installation (without any migrations) and I’m experiencing the same issue.

I’ve checked that I can retrieve the measures of my custom metrics directly from the API. The api/measures/component_tree endpoint gives me the latest values of my metrics on files, but they don’t seem to be aggregated on a directory level and on the base component level (the project).
I don’t have a MeasureComputer and I only report measures on files, which previously was aggregated automatically (as you can see on the screenshot above), but I have a feeling that now I need to do the aggregation myself. Is that something that’s changed in any of the recent versions?