fix!: glue sync metrics not exported in HMS deployments (EGDL-8247)#135
Merged
Conversation
MetricService now accepts a MeterRegistry via constructor injection so the metrics backend is determined by the caller rather than hardcoded to the global registry. ApiaryGlueSync's default constructor creates a JmxMeterRegistry, making the glue_listener_* counters visible via JMX for any attached exporter. A new three-arg constructor allows framework deployments (e.g. Dronefly/Spring Boot) to inject their own registry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… Hive's 3.x classpath Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
MetricService.configuredRegistry() now adds a JmxMeterRegistry to Metrics.globalRegistry only when no sub-registry exists (HMS/bare-JVM deployments). In Dronefly, Spring Boot autoconfiguration adds a PrometheusMeterRegistry before listeners are constructed, so the check is a no-op and metrics flow to the existing global registry unchanged. Shade and relocate metrics-jmx/metrics-core to avoid classpath conflict with Hive's bundled Codahale 3.1.0. Version remains 8.1.18-SNAPSHOT as no public API was changed vs main. Remove generated dependency-reduced-pom.xml from git tracking. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…flict Spring Boot's JmxMetricsExportAutoConfiguration uses @ConditionalOnClass (JmxMeterRegistry.class). Without relocation, the shaded JAR exposes io.micrometer.jmx.JmxMeterRegistry at its original package name, Spring Boot finds it, tries to instantiate it, and hits a NoSuchMethodError: the shaded JmxMeterRegistry calls DropwizardMeterRegistry with the relocated (shaded) Codahale MetricRegistry, but DropwizardMeterRegistry is loaded from the external micrometer-core JAR which only knows the unshaded type. Relocating io.micrometer.jmx and io.micrometer.core.instrument.dropwizard hides them from Spring Boot's classpath scanning. MetricService (also in the shaded JAR) has its bytecode rewritten by the shade plugin to use the relocated classes; the inheritance chain (shaded JmxMeterRegistry -> shaded DropwizardMeterRegistry -> MeterRegistry) still satisfies Metrics.addRegistry's MeterRegistry parameter since MeterRegistry itself is not relocated. Also pin io.dropwizard.metrics:metrics-jmx version in root dependencyManagement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove breaking change classification — no public API changed vs main. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
javsanbel2
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MetricService.configuredRegistry()now adds aJmxMeterRegistrytoMetrics.globalRegistryonly when no sub-registry is present (HMS / bare-JVM deployments)PrometheusMeterRegistrybefore listeners are constructed, so the check is a no-op and metrics flow to Prometheus unchangedmicrometer-registry-jmxdependency; shaded and relocatedmetrics-jmx/metrics-coreandio.micrometer.jmx/io.micrometer.core.instrument.dropwizardto avoid classpath conflicts with Hive'sbundled Codahale 3.1.0 and Spring Boot's JMX autoconfiguration
dependency-reduced-pom.xmlfrom git trackingmainTest plan
ApiaryGlueSyncTestpasses unchangedMetricServiceTestpasses — covers counter increment, all metrics pre-registered at zero, unknown counter ignored, and JMX MBeans queryable via platform MBean serverglue_listener_*counters appear in JMX (e.g. viajconsoleor:8080/metrics)glue_listener_*counters appear at/actuator/prometheuswith no JMX registry added to the global registryFollow-up (out of scope)
micrometer-registry-prometheusis a declared dependency, which causes theshade-all(HMS) fat JAR to bundle the Prometheus Java client unnecessarily — JMX is the only registry used in HMS. In Droneflythis also duplicates Prometheus classes on the classpath (same version so no failures, but dead weight). To fix: remove
micrometer-registry-prometheusfrom the declared dependencies and dropio.prometheus:*from theshade-allartifact includes. Dronefly gets Prometheus through Spring Boot's autoconfiguration, not from our JAR.Jira: EGDL-8247
🤖 Generated with Claude Code