Developing a plugin that imposes a metric on new code?

For context, my team is using SonarQube 7.7 Enterprise Edition.

My team would like to develop a plugin that imposes a metric on new code the same way the native “… on New Code” metrics do. Specifically, we’re interested in having the metric be applied to the quality gate on short-lived branches.

We reviewed the source for the sonarqube project and see where the Metric instances are being created here:

However, it appears that the only difference between the new-code and non-new-code metrics is the calling of .setDeleteHistoricalData(true). We tried to set this on the metrics in our plugin, but did not see them reflected in the quality gate on our short lived branches.

Since (as far as I know) the branch-handling logic in our paid version of SonarQube is not open-source, we’re wondering if the native metrics are somehow handled/registered differently such that they are allowed to apply to short-lived branches.

Could someone help us understand how to create a Metric instance that will apply to a short-lived branch?