@@ -128,6 +128,9 @@ public class HikariModule implements Extension {
128128
129129 private String database ;
130130
131+ private Object metricRegistry ;
132+ private Object healthCheckRegistry ;
133+
131134 /**
132135 * Creates a new Hikari module. The database parameter can be one of:
133136 *
@@ -165,10 +168,40 @@ public HikariModule(@Nonnull HikariConfig hikari) {
165168 this .hikari = hikari ;
166169 }
167170
171+ /**
172+ * Sets a {@code MetricRegistry} to pass it forward to
173+ * {@link HikariConfig} for instrumentation.
174+ *
175+ * @param metricRegistry an instance compatible with {@link HikariConfig#setMetricRegistry(Object)}
176+ * @return this instance
177+ * @see HikariConfig#setMetricRegistry(Object)
178+ */
179+ public HikariModule metricRegistry (Object metricRegistry ) {
180+ this .metricRegistry = metricRegistry ;
181+ return this ;
182+ }
183+
184+ /**
185+ * Sets a {@code HealthCheckRegistry} to pass it forward to
186+ * {@link HikariConfig} for instrumentation.
187+ *
188+ * @param healthCheckRegistry an instance compatible with {@link HikariConfig#setHealthCheckRegistry(Object)}
189+ * @return this instance
190+ * @see HikariConfig#setHealthCheckRegistry(Object)
191+ */
192+ public HikariModule healthCheckRegistry (Object healthCheckRegistry ) {
193+ this .healthCheckRegistry = healthCheckRegistry ;
194+ return this ;
195+ }
196+
168197 @ Override public void install (@ Nonnull Jooby application ) {
169198 if (hikari == null ) {
170199 hikari = build (application .getEnvironment (), database );
171200 }
201+
202+ if (metricRegistry != null ) hikari .setMetricRegistry (metricRegistry );
203+ if (healthCheckRegistry != null ) hikari .setHealthCheckRegistry (healthCheckRegistry );
204+
172205 HikariDataSource dataSource = new HikariDataSource (hikari );
173206
174207 ServiceRegistry registry = application .getServices ();
0 commit comments