Skip to content

Conversation

@prashantwason
Copy link
Member

@prashantwason prashantwason commented Dec 3, 2025

Describe the issue this Pull Request addresses

This PR provides the HoodieVersion class and publishes the major, minor, and patch version of HUDI as integers via the metric system. These metrics can be used to track the versions of HUDI running in production.

Summary and Changelog

Summary:

  • Added HoodieVersion class that provides semantic versioning information for HUDI code
  • Added version metrics (major, minor, patch) as integers to the metrics system
  • These metrics complement the existing version string already added to commit instants

Changelog:

  1. New HoodieVersion class (hudi-common/src/main/java/org/apache/hudi/HoodieVersion.java):

    • Provides methods to get complete version string: get()
    • Provides semantic version components: major(), minor(), patch()
    • Provides integer versions for metrics: majorAsInt(), minorAsInt(), patchAsInt()
    • Handles various version formats including snapshots and suffixes
  2. New TestHoodieVersion test class (hudi-common/src/test/java/org/apache/hudi/TestHoodieVersion.java):

    • Comprehensive unit tests for HoodieVersion functionality
    • Tests version parsing with various formats (0.12.2, 0.12.2-spark3, etc.)
    • Tests integer conversion handling edge cases
  3. Updated BaseHoodieWriteClient (hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieWriteClient.java):

    • Added import for HoodieVersion
    • Added metrics registration for version.major, version.minor, version.patch as integer gauges
    • Updated existing version metric to use HoodieVersion.get()

Impact

Public API Changes: None - This is additive only

User-Facing Changes:

  • New metrics available: version.major, version.minor, version.patch (as integers)
  • Existing version metric now uses HoodieVersion class instead of package implementation version

Performance Impact: Negligible - metrics are registered once during client initialization

Risk Level

Low

The changes are additive and do not modify existing behavior. The HoodieVersion class is straightforward with comprehensive unit tests. Metrics registration happens during client initialization and has minimal overhead.

Verification:

  • Unit tests added for HoodieVersion class covering various version formats
  • Existing metrics system integration tested
  • No breaking changes to existing APIs

Documentation Update

None required. This is an internal metrics improvement. The version information is already documented as part of commit metadata.

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

…rs via the metric system.

 These metrics can be used to track the versions of HUDI in production.

 Added HoodieVersion class and its unit test, The HoodieVersion class provides semantic versioning information for HUDI code.
@prashantwason prashantwason changed the title [HUDI-5724] Publish HUDI version metrics as integers [MINOR] Publish HUDI version metrics as integers Dec 3, 2025
@hudi-bot
Copy link
Collaborator

hudi-bot commented Dec 3, 2025

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@github-actions github-actions bot added the size:M PR with lines of changes in (100, 300] label Dec 3, 2025
Comment on lines +179 to +187
if (config.isMetricsOn()) {
// report userName and hudi version
final String version = HoodieVersion.get();
metrics.getMetrics().registerGauge(metrics.getMetricsName("userName", System.getProperty("user.name")), 1);
metrics.getMetrics().registerGauge(metrics.getMetricsName("version", StringUtils.isNullOrEmpty(version) ? "0.14.x" : version), 1);
metrics.getMetrics().registerGauge("version.major", HoodieVersion.majorAsInt());
metrics.getMetrics().registerGauge("version.minor", HoodieVersion.minorAsInt());
metrics.getMetrics().registerGauge("version.patch", HoodieVersion.patchAsInt());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the logic be put into HoodieMetrics class, similar to HoodieMetrics#emitIndexTypeMetrics?

Comment on lines +184 to +186
metrics.getMetrics().registerGauge("version.major", HoodieVersion.majorAsInt());
metrics.getMetrics().registerGauge("version.minor", HoodieVersion.minorAsInt());
metrics.getMetrics().registerGauge("version.patch", HoodieVersion.patchAsInt());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these still needed if the full version is published?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M PR with lines of changes in (100, 300]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants