spa77k opened a new pull request, #14884: URL: https://github.com/apache/gravitino/pull/14884
### What changes were proposed in this pull request? - `plugins/maintenance` and `plugins/idp-basic` now apply `libs.plugins.aspectj.post.compile.weaving`, depend on `aspectjrt`, and weave `MethodMonitorAspect` from `core` into their own classes. - `core` builds an extra `aspects` jar (classifier `aspects`, exposed through an `aspects` configuration) that holds only the unshaded `MethodMonitorAspect` class. The plugins weave from this jar. - The plugins add it through their own `monitoredAspect` configuration to the main source set's aspect path, not through the plugin's `aspect` configuration. `aspect` is extended by `implementation`, so it would put the aspect jar on the runtime classpath (it ended up in the maintenance plugin's copied libs), where `core` already provides the aspect. - New tests in `core` and in each plugin replace the aspect's metrics system with a fresh one, call monitored methods, and assert the `<baseMetricName>.total` / `.success` / `.failure` counts. - Not changed: the optional rename of the `ViewMetaService.updateView` metric (`updateViewByIdentifier`), to keep existing metric names. ### Why are the changes needed? `MethodMonitorAspect` is applied by AspectJ post-compile weaving, and only `core` applied that plugin. The 34 `@Monitored` annotations in `plugins/maintenance` and `plugins/idp-basic` were no-ops and never recorded metrics. `core` cannot be used directly as the aspect path. Its published jar is the shadow jar that relocates `org.antlr.v4.runtime`, and relocation rewrites the constant pools of its woven classes. ajc then fails with `ClassCastException` (`ConstantNameAndType cannot be cast to ConstantUtf8`) while reading their AspectJ attributes. This is why the separate `aspects` jar is needed. Fix #14834 ### Does this PR introduce _any_ user-facing change? The 34 `@Monitored` methods in the two plugins now record metrics in the relational store metrics source, so new metrics appear. No API or configuration changes. ### How was this patch tested? - New tests: `TestMetaServiceMetrics` in `core` (`listMetalakes` success, `getMetalakeIdByName` failure on a missing metalake), `TestIdpMetaServiceMetrics` in `idp-basic` (`getIdpUserByUsername` success and failure, `getIdpGroupByName`), and `TestMaintenanceMetaServiceMetrics` in `maintenance` (`insertTableSnapshotMetrics`, `getTableSnapshotMetricsById`). They pass. The `core` test was run locally in the `coreH2Test` lane only. - Removing the weaving from `idp-basic` makes its new test fail. - `javap` on the built plugin jars shows all 34 monitored methods woven (calls to `MethodMonitorAspect.aspectOf`). - `:plugins:idp-basic:build` (121 tests) and `:plugins:maintenance:build` (89 tests) passed. - `:core:spotlessCheck` passed. -- 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]
