20
20
import io .micrometer .common .lang .NonNull ;
21
21
import io .micrometer .common .lang .Nullable ;
22
22
23
+ import java .util .Arrays ;
23
24
import java .util .HashMap ;
24
25
import java .util .LinkedHashMap ;
25
26
import java .util .Map ;
@@ -941,6 +942,30 @@ public Context addHighCardinalityKeyValue(KeyValue keyValue) {
941
942
return this ;
942
943
}
943
944
945
+ /**
946
+ * Removes a low cardinality key value by looking at its key - those will be
947
+ * removed to those fetched from the
948
+ * {@link ObservationConvention#getLowCardinalityKeyValues(Context)} method.
949
+ * @param keyName name of the key
950
+ * @return this context
951
+ */
952
+ public Context removeLowCardinalityKeyValue (String keyName ) {
953
+ this .lowCardinalityKeyValues .remove (keyName );
954
+ return this ;
955
+ }
956
+
957
+ /**
958
+ * Removes a high cardinality key value by looking at its key - those will be
959
+ * removed to those fetched from the
960
+ * {@link ObservationConvention#getHighCardinalityKeyValues(Context)} method.
961
+ * @param keyName name of the key
962
+ * @return this context
963
+ */
964
+ public Context removeHighCardinalityKeyValue (String keyName ) {
965
+ this .highCardinalityKeyValues .remove (keyName );
966
+ return this ;
967
+ }
968
+
944
969
/**
945
970
* Adds multiple low cardinality key values at once.
946
971
* @param keyValues collection of key values
@@ -961,6 +986,26 @@ public Context addHighCardinalityKeyValues(KeyValues keyValues) {
961
986
return this ;
962
987
}
963
988
989
+ /**
990
+ * Removes multiple low cardinality key values at once.
991
+ * @param keyNames collection of key names
992
+ * @return this context
993
+ */
994
+ public Context removeLowCardinalityKeyValues (String ... keyNames ) {
995
+ Arrays .stream (keyNames ).forEach (this ::removeLowCardinalityKeyValue );
996
+ return this ;
997
+ }
998
+
999
+ /**
1000
+ * Removes multiple high cardinality key values at once.
1001
+ * @param keyNames collection of key names
1002
+ * @return this context
1003
+ */
1004
+ public Context removeHighCardinalityKeyValues (String ... keyNames ) {
1005
+ Arrays .stream (keyNames ).forEach (this ::removeHighCardinalityKeyValue );
1006
+ return this ;
1007
+ }
1008
+
964
1009
@ NonNull
965
1010
@ Override
966
1011
public KeyValues getLowCardinalityKeyValues () {
0 commit comments