shangxinli opened a new pull request, #19108:
URL: https://github.com/apache/hudi/pull/19108

   ### Describe the issue this Pull Request addresses
   
   The metrics surface does not expose the on-disk Hudi table version. 
Operators upgrading across major Hudi versions — particularly anyone running 
with `hoodie.write.auto.upgrade=false` and a pinned 
`hoodie.write.table.version` — currently have no observability signal to alert 
when a table is unexpectedly promoted to a newer table version. This change 
fills that gap with a one-shot gauge emitted on every write / table-service 
client init, so standard alerting (Prometheus / Datadog / Graphite / JMX) can 
flag the drift in near real time.
   
   ### Summary and Changelog
   
   - Adds `HoodieMetrics#emitTableVersionMetric(int)` which registers a 
`table.tableVersion` gauge in the metrics registry.
   - `BaseHoodieClient` calls it once per client construction after loading the 
table's metaClient.
   - Best-effort: if the table has not yet been initialized (first-ever write 
to a new base path) the metaClient load throws and we log at DEBUG and skip; 
the gauge will surface on the next client init after the table exists.
   - No-op when metrics are disabled (`config.isMetricsOn() == false`).
   - Adds unit tests in `TestHoodieMetrics` covering both the enabled and 
disabled paths.
   
   ### Impact
   
   Pure additive change. No on-disk state, no schema change, no behavior change 
for tables that disable metrics. Existing callers unaffected.
   
   Gauge name: `<metric.prefix>.<tableName>.table.tableVersion`
   Value: integer `HoodieTableVersion#versionCode()` (e.g. `6`, `8`)
   
   ### Risk Level
   
   none — additive metric only.
   
   ### Documentation Update
   
   none — surfaced through the existing reporter infrastructure; no new config.
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to