2020import java .util .Map ;
2121import java .util .function .Function ;
2222
23- import io .micrometer .core .instrument .Meter ;
2423import io .micrometer .core .instrument .MeterRegistry ;
2524import io .micrometer .core .instrument .Tag ;
2625import io .micrometer .core .instrument .Tags ;
@@ -64,7 +63,7 @@ public class MetricsRetryListener implements RetryListener {
6463
6564 private final Map <RetryContext , Timer .Sample > retryContextToSample = new IdentityHashMap <>();
6665
67- private final Meter . MeterProvider < Timer > retryMeterProvider ;
66+ private final Timer . Builder retryMeterProvider ;
6867
6968 private Tags customTags = Tags .empty ();
7069
@@ -77,9 +76,7 @@ public class MetricsRetryListener implements RetryListener {
7776 public MetricsRetryListener (MeterRegistry meterRegistry ) {
7877 Assert .notNull (meterRegistry , "'meterRegistry' must not be null" );
7978 this .meterRegistry = meterRegistry ;
80- this .retryMeterProvider = Timer .builder (TIMER_NAME )
81- .description ("Metrics for Spring RetryTemplate" )
82- .withRegistry (this .meterRegistry );
79+ this .retryMeterProvider = Timer .builder (TIMER_NAME ).description ("Metrics for Spring RetryTemplate" );
8380 }
8481
8582 /**
@@ -122,7 +119,7 @@ public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T
122119 .and (this .customTagsProvider .apply (context ))
123120 .and ("exception" , throwable != null ? throwable .getClass ().getSimpleName () : "none" );
124121
125- sample .stop (this .retryMeterProvider .withTags (retryTags ));
122+ sample .stop (this .retryMeterProvider .tags (retryTags ). register ( this . meterRegistry ));
126123 }
127124
128125}
0 commit comments