HikariCP icon indicating copy to clipboard operation
HikariCP copied to clipboard

Deprecate setMetricRegistry in favour of setMetricsTrackerFactory

Open NersesAM opened this issue 7 years ago • 1 comments

Following up on my yesterday's PR #1089. Even though it is ok, I think the fact of accepting an Object and then doing tricks to find out wether the library class is in classpath and later on casting the object to correct type are not very nice. This is especially not great in light of Change in dropwizard metrics package name in upcoming v5. For some time we will need to support both versions. This will add even more complexity in that part of the code.

That's why I propose to deprecate/delete setMetricRegistry in favour of setMetricsTrackerFactory. Also by providing overloaded static factory methods in the MetricsTrackerFactory interface we won't need to do type checks at all. Users can just use setMetricsTrackerFactory(from(metricRegistry)) instead of setMetricRegistry(metricRegistry) allowing to greatly simplify code around registering metricRegsitry . This is preliminary PR just to get your feedback. Can update it with complete removal. WDYT?

NersesAM avatar Feb 19 '18 01:02 NersesAM

Codecov Report

Merging #1091 into dev will decrease coverage by 0.75%. The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev    #1091      +/-   ##
============================================
- Coverage     72.98%   72.23%   -0.76%     
+ Complexity      557      551       -6     
============================================
  Files            24       24              
  Lines          1940     1945       +5     
  Branches        258      261       +3     
============================================
- Hits           1416     1405      -11     
- Misses          369      372       +3     
- Partials        155      168      +13
Impacted Files Coverage Δ Complexity Δ
src/main/java/com/zaxxer/hikari/HikariConfig.java 68.18% <ø> (-2.5%) 125 <0> (ø)
.../main/java/com/zaxxer/hikari/HikariDataSource.java 65.04% <ø> (-6.04%) 29 <0> (-4)
...c/main/java/com/zaxxer/hikari/pool/HikariPool.java 83.96% <ø> (+1.13%) 58 <0> (ø) :arrow_down:
src/main/java/com/zaxxer/hikari/pool/PoolBase.java 69.48% <0%> (-0.23%) 52% <0%> (-2%)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 36ffcaf...c084d54. Read the comment docs.

codecov[bot] avatar Feb 19 '18 01:02 codecov[bot]