Introduce new metrics git.info and build.info that expose some information from GitProperties and BuildProperties respectively, if available. This is the same info that /actuator/info provides, but represented as metrics, which allows for convenient integration in Grafana dashboards.

Using tags on a pseudo gauge seems to be the standard way of doing this; see for example Prometheus' go_info metric or Micrometer's own jvm.info metric (not yet included in Spring Boot).

Build runs locally, auto formatter has been applied, Checkstyle has no objections.

Comment From: wilkinsona

See #12348 for some history on this topic and https://github.com/micrometer-metrics/micrometer/pull/2221 for the addition of jvm.info to Micrometer.

Comment From: jonatan-ivanov

I think this makes as much sense (if not more) as https://github.com/micrometer-metrics/micrometer/pull/2221. Also, what everyone thinks (/cc @shakuzen) about adding a GitInfoMetrics and a BuildInfoMetrics class or maybe just BuildInfoMetrics (that does both) to Micrometer? The users need to supply the data (e.g.: through ctor) but it would give a simple contract about what needs to be provided and what will be produced. The advantage of doing it is having the same naming convention across Micrometer users also for non spring boot apps.

Comment From: wilkinsona

Thanks for taking a look, @jonatan-ivanov.

The advantage of doing it is having the same naming convention across Micrometer users also for non spring boot apps

That's quite a compelling advantage. +1 from me, FWIW.

Comment From: mafr

Thanks for your feedback, everyone! If there's consensus on this, I'm happy to make a PR against Micrometer to add GitInfoMetrics and BuildInfoMetrics (with the suggested changes) and later adjust this PR to use them (maybe add JvmMetrics while I'm at it).

Comment From: shakuzen

If this is worth doing, I agree something in Micrometer standardizing it irrespective of framework would be a worthwhile goal. I'm not sure exactly what it would look like, since there isn't a generic git/build info class like Boot has.

which allows for convenient integration in Grafana dashboards.

I'd like to better understand the use cases we're trying to enable to make sure we're doing it in the best way for most users. I talked to @jonatan-ivanov today a bit about my concern over how well these kinds of info metrics can be used across different metrics backends. Prometheus consistently seems to be the backend people requesting it are using, and I want to make sure it is useful in other backends as well. We can discuss that more in the Micrometer repo or Slack.

Comment From: wilkinsona

Thanks, @shakuzen. I'll place this PR on hold until the discussion in the Micrometer repo or Slack has reached a conclusion. Could you please link to the discussion once it's begun as I'd like to follow along if I can.

Comment From: snicoll

The observability team has been discussing this and we need some work on Micrometer first. Let's follow-up on the issue you've created there and we can revisit this once that completes. Thanks for the PR, in any case!