Conversation
Added a method to load git properties from the classpath and include the git commit SHA in emitted metrics.
There was a problem hiding this comment.
Thanks @razinbouzar! It’s useful to have this to track service health across rolling deployments with the same version. Left some high-level thoughts.
- Please document the new dimension in metrics.md: https://druid.apache.org/docs/latest/operations/metrics/ (something like a high level info note would suffice)
- Once the new dimension is in, we can also add the same info to
sys.serverstable similar to #18542. This would provide a SQL-friendly way to verify that clusters are running the intended commit, version, etc.
| private static Map<String, String> loadGitProperties() | ||
| { | ||
| try (InputStream is = EmitterModule.class.getClassLoader().getResourceAsStream("git.properties")) { | ||
| if (is != null) { | ||
| Properties props = new Properties(); | ||
| props.load(is); | ||
|
|
||
| // Convert Properties to Map<String, String> | ||
| Map<String, String> gitProperties = new HashMap<>(); | ||
| for (String key : props.stringPropertyNames()) { | ||
| String value = props.getProperty(key); | ||
| if (value != null && !value.trim().isEmpty()) { | ||
| gitProperties.put(key, value.trim()); | ||
| } | ||
| } | ||
|
|
||
| return gitProperties; |
There was a problem hiding this comment.
On the approach, I'm wondering whether using git.properties from the class loader vs using META-INF/MANIFEST.MF (produced by the JAR build) would be better.
Is the former coming from git-commit-id-maven-plugin: https://github.com/apache/druid/blob/master/pom.xml#L1878-L1903?
The latter should be available through https://github.com/apache/druid/blob/master/pom.xml#L1870:
Build-Revision: 1c2eb65...
Build-Version: 37.0.0-SNAPSHOT
Looks like version internally reads from the manifest as well: String version = getClass().getPackage().getImplementationVersion()
But those are standard properties, so we may want a small utility to read the Git SHA / build revision from the manifest, such as the Build-Revision property. I’ll also give it some thought.
| } else { | ||
| // Fallback value when git properties are not available | ||
| extraServiceDimensions | ||
| .addBinding("gitSha") |
There was a problem hiding this comment.
Thoughts on naming: gitSha or buildRevision or something else?
Adding a git commit sha as an emitted metric for version tracking.
Fixes #XXXX.
Description
Fixed the bug ...
Renamed the class ...
Added a forbidden-apis entry ...
Release note
Key changed/added classes in this PR
MyFooOurBarTheirBazThis PR has: