2020import io .micrometer .common .util .internal .logging .InternalLoggerFactory ;
2121import io .micrometer .common .util .internal .logging .WarnThenDebugLogger ;
2222import io .micrometer .core .annotation .Incubating ;
23- import io .micrometer .core .instrument .Meter .Id ;
2423import io .micrometer .core .instrument .config .MeterFilter ;
2524import io .micrometer .core .instrument .config .MeterFilterReply ;
2625import io .micrometer .core .instrument .config .NamingConvention ;
@@ -102,35 +101,36 @@ public abstract class MeterRegistry {
102101 * supported. Hence, we use CHM to support that iteration without
103102 * ConcurrentModificationException risk.
104103 */
105- private final Map <Id , Meter > meterMap = new ConcurrentHashMap <>();
104+ private final Map <Meter . Id , Meter > meterMap = new ConcurrentHashMap <>();
106105
107106 /**
108107 * write/remove guarded by meterMapLock, read in
109- * {@link #getOrCreateMeter(DistributionStatisticConfig, BiFunction, Id, Function)} is
110- * unguarded
108+ * {@link #getOrCreateMeter(DistributionStatisticConfig, BiFunction, Meter. Id, Function)}
109+ * is unguarded
111110 */
112- private final Map <Id , Meter > preFilterIdToMeterMap = new HashMap <>();
111+ private final Map <Meter . Id , Meter > preFilterIdToMeterMap = new HashMap <>();
113112
114113 /**
115114 * For reverse looking up pre-filter ID in {@link #preFilterIdToMeterMap} from the
116- * Meter being removed in {@link #remove(Id)}. Guarded by the {@link #meterMapLock}.
115+ * Meter being removed in {@link #remove(Meter.Id)}. Guarded by the
116+ * {@link #meterMapLock}.
117117 */
118- private final Map <Meter , Id > meterToPreFilterIdMap = new HashMap <>();
118+ private final Map <Meter , Meter . Id > meterToPreFilterIdMap = new HashMap <>();
119119
120120 /**
121121 * Only needed when MeterFilter configured after Meters registered. Write/remove
122- * guarded by meterMapLock, remove in {@link #unmarkStaleId(Id)} and other operations
123- * unguarded
122+ * guarded by meterMapLock, remove in {@link #unmarkStaleId(Meter. Id)} and other
123+ * operations unguarded
124124 */
125- private final Set <Id > stalePreFilterIds = new HashSet <>();
125+ private final Set <Meter . Id > stalePreFilterIds = new HashSet <>();
126126
127127 /**
128128 * Map of meter id whose associated meter contains synthetic counterparts to those
129129 * synthetic ids. We maintain these associations so that when we remove a meter with
130130 * synthetics, they can removed as well.
131131 */
132132 // Guarded by meterMapLock for both reads and writes
133- private final Map <Id , Set <Id >> syntheticAssociations = new HashMap <>();
133+ private final Map <Meter . Id , Set <Meter . Id >> syntheticAssociations = new HashMap <>();
134134
135135 private final AtomicBoolean closed = new AtomicBoolean ();
136136
@@ -255,7 +255,7 @@ protected <T> TimeGauge newTimeGauge(Meter.Id id, @Nullable T obj, TimeUnit valu
255255
256256 return new TimeGauge () {
257257 @ Override
258- public Id getId () {
258+ public Meter . Id getId () {
259259 return withUnit ;
260260 }
261261
@@ -298,7 +298,7 @@ protected abstract <T> FunctionTimer newFunctionTimer(Meter.Id id, T obj, ToLong
298298 * measurement.
299299 * @return A new function counter.
300300 */
301- protected abstract <T > FunctionCounter newFunctionCounter (Id id , T obj , ToDoubleFunction <T > countFunction );
301+ protected abstract <T > FunctionCounter newFunctionCounter (Meter . Id id , T obj , ToDoubleFunction <T > countFunction );
302302
303303 protected List <Tag > getConventionTags (Meter .Id id ) {
304304 return id .getConventionTags (config ().namingConvention ());
@@ -622,28 +622,28 @@ private <M extends Meter> M registerMeterIfNecessary(Class<M> meterClass, Meter.
622622 return meterClass .cast (m );
623623 }
624624
625- private Id getMappedId (Id id ) {
625+ private Meter . Id getMappedId (Meter . Id id ) {
626626 if (id .syntheticAssociation () != null ) {
627627 return id ;
628628 }
629- Id mappedId = id ;
629+ Meter . Id mappedId = id ;
630630 for (MeterFilter filter : filters ) {
631631 mappedId = filter .map (mappedId );
632632 }
633633 return mappedId ;
634634 }
635635
636636 private Meter getOrCreateMeter (@ Nullable DistributionStatisticConfig config ,
637- BiFunction <Id , /* Nullable Generic */ DistributionStatisticConfig , ? extends Meter > builder , Id originalId ,
638- Function <Meter .Id , ? extends Meter > noopBuilder ) {
637+ BiFunction <Meter . Id , /* Nullable Generic */ DistributionStatisticConfig , ? extends Meter > builder ,
638+ Meter . Id originalId , Function <Meter .Id , ? extends Meter > noopBuilder ) {
639639
640640 Meter m = preFilterIdToMeterMap .get (originalId );
641641 if (m != null && !isStaleId (originalId )) {
642642 checkAndWarnAboutDoubleRegistration (m );
643643 return m ;
644644 }
645645
646- Id mappedId = getMappedId (originalId );
646+ Meter . Id mappedId = getMappedId (originalId );
647647 m = meterMap .get (mappedId );
648648
649649 if (m != null ) {
@@ -678,9 +678,10 @@ private Meter getOrCreateMeter(@Nullable DistributionStatisticConfig config,
678678
679679 m = builder .apply (mappedId , config );
680680
681- Id synAssoc = mappedId .syntheticAssociation ();
681+ Meter . Id synAssoc = mappedId .syntheticAssociation ();
682682 if (synAssoc != null ) {
683- Set <Id > associations = syntheticAssociations .computeIfAbsent (synAssoc , k -> new HashSet <>());
683+ Set <Meter .Id > associations = syntheticAssociations .computeIfAbsent (synAssoc ,
684+ k -> new HashSet <>());
684685 associations .add (mappedId );
685686 }
686687
@@ -698,7 +699,7 @@ private Meter getOrCreateMeter(@Nullable DistributionStatisticConfig config,
698699 return m ;
699700 }
700701
701- private boolean isStaleId (Id originalId ) {
702+ private boolean isStaleId (Meter . Id originalId ) {
702703 return !stalePreFilterIds .isEmpty () && stalePreFilterIds .contains (originalId );
703704 }
704705
@@ -707,7 +708,7 @@ private boolean isStaleId(Id originalId) {
707708 * @param originalId id before any filter mapping has been applied
708709 * @return {@code true} if the id is stale
709710 */
710- private boolean unmarkStaleId (Id originalId ) {
711+ private boolean unmarkStaleId (Meter . Id originalId ) {
711712 return !stalePreFilterIds .isEmpty () && stalePreFilterIds .remove (originalId );
712713 }
713714
@@ -743,8 +744,8 @@ else if (reply == MeterFilterReply.ACCEPT) {
743744
744745 /**
745746 * Remove a {@link Meter} from this {@link MeterRegistry registry}. This is expected
746- * to be a {@link Meter} with the same {@link Id} returned when registering a meter -
747- * which will have {@link MeterFilter}s applied to it.
747+ * to be a {@link Meter} with the same {@link Meter. Id} returned when registering a
748+ * meter - which will have {@link MeterFilter}s applied to it.
748749 * @param meter The meter to remove
749750 * @return The removed meter, or null if the provided meter is not currently
750751 * registered.
@@ -758,8 +759,8 @@ public Meter remove(Meter meter) {
758759
759760 /**
760761 * Remove a {@link Meter} from this {@link MeterRegistry registry} based on its
761- * {@link Id} before applying this registry's {@link MeterFilter}s to the given
762- * {@link Id}.
762+ * {@link Meter. Id} before applying this registry's {@link MeterFilter}s to the given
763+ * {@link Meter. Id}.
763764 * @param preFilterId the id of the meter to remove
764765 * @return The removed meter, or null if the meter is not found
765766 * @since 1.3.16
@@ -775,9 +776,9 @@ public Meter removeByPreFilterId(Meter.Id preFilterId) {
775776
776777 /**
777778 * Remove a {@link Meter} from this {@link MeterRegistry registry} based the given
778- * {@link Id} as-is. The registry's {@link MeterFilter}s will not be applied to it.
779- * You can use the {@link Id} of the {@link Meter} returned when registering a meter,
780- * since that will have {@link MeterFilter}s already applied to it.
779+ * {@link Meter. Id} as-is. The registry's {@link MeterFilter}s will not be applied to
780+ * it. You can use the {@link Meter. Id} of the {@link Meter} returned when registering
781+ * a meter, since that will have {@link MeterFilter}s already applied to it.
781782 * @param mappedId The id of the meter to remove
782783 * @return The removed meter, or null if no meter matched the provided id.
783784 * @since 1.1.0
@@ -789,13 +790,13 @@ public Meter remove(Meter.Id mappedId) {
789790 synchronized (meterMapLock ) {
790791 final Meter removedMeter = meterMap .remove (mappedId );
791792 if (removedMeter != null ) {
792- Id preFilterIdToRemove = meterToPreFilterIdMap .remove (removedMeter );
793+ Meter . Id preFilterIdToRemove = meterToPreFilterIdMap .remove (removedMeter );
793794 preFilterIdToMeterMap .remove (preFilterIdToRemove );
794795 stalePreFilterIds .remove (preFilterIdToRemove );
795796
796- Set <Id > synthetics = syntheticAssociations .remove (mappedId );
797+ Set <Meter . Id > synthetics = syntheticAssociations .remove (mappedId );
797798 if (synthetics != null ) {
798- for (Id synthetic : synthetics ) {
799+ for (Meter . Id synthetic : synthetics ) {
799800 remove (synthetic );
800801 }
801802 }
@@ -913,7 +914,7 @@ public Config onMeterRemoved(Consumer<Meter> meterRemovedListener) {
913914 * @since 1.6.0
914915 */
915916 @ Incubating (since = "1.6.0" )
916- public Config onMeterRegistrationFailed (BiConsumer <Id , String > meterRegistrationFailedListener ) {
917+ public Config onMeterRegistrationFailed (BiConsumer <Meter . Id , String > meterRegistrationFailedListener ) {
917918 meterRegistrationFailedListeners .add (meterRegistrationFailedListener );
918919 return this ;
919920 }
@@ -1213,23 +1214,23 @@ public boolean isClosed() {
12131214 * @since 1.6.0
12141215 */
12151216 protected void meterRegistrationFailed (Meter .Id id , @ Nullable String reason ) {
1216- for (BiConsumer <Id , String > listener : meterRegistrationFailedListeners ) {
1217+ for (BiConsumer <Meter . Id , String > listener : meterRegistrationFailedListeners ) {
12171218 listener .accept (id , reason );
12181219 }
12191220 }
12201221
12211222 // VisibleForTesting
1222- Map <Id , Meter > _getPreFilterIdToMeterMap () {
1223+ Map <Meter . Id , Meter > _getPreFilterIdToMeterMap () {
12231224 return Collections .unmodifiableMap (preFilterIdToMeterMap );
12241225 }
12251226
12261227 // VisibleForTesting
1227- Map <Meter , Id > _getMeterToPreFilterIdMap () {
1228+ Map <Meter , Meter . Id > _getMeterToPreFilterIdMap () {
12281229 return Collections .unmodifiableMap (meterToPreFilterIdMap );
12291230 }
12301231
12311232 // VisibleForTesting
1232- Set <Id > _getStalePreFilterIds () {
1233+ Set <Meter . Id > _getStalePreFilterIds () {
12331234 return Collections .unmodifiableSet (stalePreFilterIds );
12341235 }
12351236
0 commit comments