diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml
index 385f0867ac..f33573f4ca 100644
--- a/error-prone-contrib/pom.xml
+++ b/error-prone-contrib/pom.xml
@@ -87,6 +87,11 @@
guava
provided
+
+ io.micrometer
+ micrometer-core
+ provided
+
io.projectreactor
reactor-core
diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MicrometerRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MicrometerRules.java
new file mode 100644
index 0000000000..40800c6d09
--- /dev/null
+++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MicrometerRules.java
@@ -0,0 +1,88 @@
+package tech.picnic.errorprone.refasterrules;
+
+import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.errorprone.refaster.Refaster;
+import com.google.errorprone.refaster.annotation.AfterTemplate;
+import com.google.errorprone.refaster.annotation.BeforeTemplate;
+import io.micrometer.core.instrument.Tag;
+import io.micrometer.core.instrument.Tags;
+import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation;
+
+/** Refaster rules related to expressions dealing with Micrometer. */
+// XXX: Consider replacing the `TagsOf[N]` rules with a bug checker, so that various other
+// expressions (e.g. those creating other collection types, those passing in tags some other way, or
+// those passing in more tags) can be replaced as wel.
+@OnlineDocumentation
+final class MicrometerRules {
+ private MicrometerRules() {}
+
+ /** Prefer using {@link Tags} over other immutable collections. */
+ static final class TagsOf1 {
+ @BeforeTemplate
+ ImmutableCollection before(Tag tag) {
+ return Refaster.anyOf(ImmutableSet.of(tag), ImmutableList.of(tag));
+ }
+
+ @AfterTemplate
+ Iterable after(Tag tag) {
+ return Tags.of(tag);
+ }
+ }
+
+ /** Prefer using {@link Tags} over other immutable collections. */
+ static final class TagsOf2 {
+ @BeforeTemplate
+ ImmutableCollection before(Tag tag1, Tag tag2) {
+ return Refaster.anyOf(ImmutableSet.of(tag1, tag2), ImmutableList.of(tag1, tag2));
+ }
+
+ @AfterTemplate
+ Iterable after(Tag tag1, Tag tag2) {
+ return Tags.of(tag1, tag2);
+ }
+ }
+
+ /** Prefer using {@link Tags} over other immutable collections. */
+ static final class TagsOf3 {
+ @BeforeTemplate
+ ImmutableCollection before(Tag tag1, Tag tag2, Tag tag3) {
+ return Refaster.anyOf(ImmutableSet.of(tag1, tag2, tag3), ImmutableList.of(tag1, tag2, tag3));
+ }
+
+ @AfterTemplate
+ Iterable after(Tag tag1, Tag tag2, Tag tag3) {
+ return Tags.of(tag1, tag2, tag3);
+ }
+ }
+
+ /** Prefer using {@link Tags} over other immutable collections. */
+ static final class TagsOf4 {
+ @BeforeTemplate
+ ImmutableCollection before(Tag tag1, Tag tag2, Tag tag3, Tag tag4) {
+ return Refaster.anyOf(
+ ImmutableSet.of(tag1, tag2, tag3, tag4), ImmutableList.of(tag1, tag2, tag3, tag4));
+ }
+
+ @AfterTemplate
+ Iterable after(Tag tag1, Tag tag2, Tag tag3, Tag tag4) {
+ return Tags.of(tag1, tag2, tag3, tag4);
+ }
+ }
+
+ /** Prefer using {@link Tags} over other immutable collections. */
+ static final class TagsOf5 {
+ @BeforeTemplate
+ ImmutableCollection before(Tag tag1, Tag tag2, Tag tag3, Tag tag4, Tag tag5) {
+ return Refaster.anyOf(
+ ImmutableSet.of(tag1, tag2, tag3, tag4, tag5),
+ ImmutableList.of(tag1, tag2, tag3, tag4, tag5));
+ }
+
+ @AfterTemplate
+ Iterable after(Tag tag1, Tag tag2, Tag tag3, Tag tag4, Tag tag5) {
+ return Tags.of(tag1, tag2, tag3, tag4, tag5);
+ }
+ }
+}
diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java
index 30839af965..fd5cb29672 100644
--- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java
+++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java
@@ -59,6 +59,7 @@ final class RefasterRulesTest {
LongStreamRules.class,
MapEntryRules.class,
MapRules.class,
+ MicrometerRules.class,
MockitoRules.class,
MultimapRules.class,
NullRules.class,
diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestInput.java
new file mode 100644
index 0000000000..256c9494bb
--- /dev/null
+++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MicrometerRulesTestInput.java
@@ -0,0 +1,57 @@
+package tech.picnic.errorprone.refasterrules;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import io.micrometer.core.instrument.Tag;
+import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase;
+
+final class MicrometerRulesTest implements RefasterRuleCollectionTestCase {
+ @Override
+ public ImmutableSet
+
+ io.micrometer
+ micrometer-core
+ 1.13.6
+
io.projectreactor
reactor-bom