Skip to content

Commit 5dca43e

Browse files
izeyebclozel
authored andcommitted
Use KeyValue.NONE_VALUE where possible
See micrometer-metrics/micrometer#3458 Closes gh-29342
1 parent b7ee797 commit 5dca43e

File tree

8 files changed

+26
-22
lines changed

8 files changed

+26
-22
lines changed

spring-web/src/main/java/org/springframework/http/client/observation/ClientHttpObservationDocumentation.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.http.client.observation;
1818

19+
import io.micrometer.common.KeyValue;
1920
import io.micrometer.common.docs.KeyName;
2021
import io.micrometer.observation.Observation;
2122
import io.micrometer.observation.ObservationConvention;
@@ -57,7 +58,7 @@ public KeyName[] getHighCardinalityKeyNames() {
5758
public enum LowCardinalityKeyNames implements KeyName {
5859

5960
/**
60-
* Name of HTTP request method or {@code "none"} if the request could not be created.
61+
* Name of HTTP request method or {@value KeyValue#NONE_VALUE} if the request could not be created.
6162
*/
6263
METHOD {
6364
@Override
@@ -68,7 +69,7 @@ public String asString() {
6869
},
6970

7071
/**
71-
* URI template used for HTTP request, or {@code "none"} if none was provided.
72+
* URI template used for HTTP request, or {@value KeyValue#NONE_VALUE} if none was provided.
7273
*/
7374
URI {
7475
@Override
@@ -89,7 +90,7 @@ public String asString() {
8990
},
9091

9192
/**
92-
* Name of the exception thrown during the exchange, or {@code "none"} if no exception happened.
93+
* Name of the exception thrown during the exchange, or {@value KeyValue#NONE_VALUE} if no exception happened.
9394
*/
9495
EXCEPTION {
9596
@Override

spring-web/src/main/java/org/springframework/http/client/observation/DefaultClientRequestObservationConvention.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
3737

3838
private static final String DEFAULT_NAME = "http.client.requests";
3939

40-
private static final KeyValue URI_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.URI, "none");
40+
private static final KeyValue URI_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.URI, KeyValue.NONE_VALUE);
4141

42-
private static final KeyValue METHOD_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.METHOD, "none");
42+
private static final KeyValue METHOD_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.METHOD, KeyValue.NONE_VALUE);
4343

4444
private static final KeyValue STATUS_IO_ERROR = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.STATUS, "IO_ERROR");
4545

@@ -49,11 +49,11 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
4949

5050
private static final KeyValue HTTP_OUTCOME_UNKNOWN = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.OUTCOME, "UNKNOWN");
5151

52-
private static final KeyValue EXCEPTION_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.EXCEPTION, "none");
52+
private static final KeyValue EXCEPTION_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.EXCEPTION, KeyValue.NONE_VALUE);
5353

54-
private static final KeyValue HTTP_URL_NONE = KeyValue.of(ClientHttpObservationDocumentation.HighCardinalityKeyNames.HTTP_URL, "none");
54+
private static final KeyValue HTTP_URL_NONE = KeyValue.of(ClientHttpObservationDocumentation.HighCardinalityKeyNames.HTTP_URL, KeyValue.NONE_VALUE);
5555

56-
private static final KeyValue CLIENT_NAME_NONE = KeyValue.of(ClientHttpObservationDocumentation.HighCardinalityKeyNames.CLIENT_NAME, "none");
56+
private static final KeyValue CLIENT_NAME_NONE = KeyValue.of(ClientHttpObservationDocumentation.HighCardinalityKeyNames.CLIENT_NAME, KeyValue.NONE_VALUE);
5757

5858

5959
private final String name;

spring-web/src/main/java/org/springframework/http/observation/DefaultServerRequestObservationConvention.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class DefaultServerRequestObservationConvention implements ServerRequestO
4848

4949
private static final KeyValue URI_REDIRECTION = KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.URI, "REDIRECTION");
5050

51-
private static final KeyValue EXCEPTION_NONE = KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.EXCEPTION, "none");
51+
private static final KeyValue EXCEPTION_NONE = KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.EXCEPTION, KeyValue.NONE_VALUE);
5252

5353
private static final KeyValue HTTP_URL_UNKNOWN = KeyValue.of(ServerHttpObservationDocumentation.HighCardinalityKeyNames.HTTP_URL, "UNKNOWN");
5454

spring-web/src/main/java/org/springframework/http/observation/ServerHttpObservationDocumentation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.http.observation;
1818

19+
import io.micrometer.common.KeyValue;
1920
import io.micrometer.common.docs.KeyName;
2021
import io.micrometer.observation.Observation;
2122
import io.micrometer.observation.ObservationConvention;
@@ -55,7 +56,7 @@ public KeyName[] getHighCardinalityKeyNames() {
5556
public enum LowCardinalityKeyNames implements KeyName {
5657

5758
/**
58-
* Name of HTTP request method or {@code "none"} if the request was not received properly.
59+
* Name of HTTP request method or {@value KeyValue#NONE_VALUE} if the request was not received properly.
5960
*/
6061
METHOD {
6162
@Override
@@ -88,7 +89,7 @@ public String asString() {
8889
},
8990

9091
/**
91-
* Name of the exception thrown during the exchange, or {@code "none"} if no exception happened.
92+
* Name of the exception thrown during the exchange, or {@value KeyValue#NONE_VALUE}} if no exception happened.
9293
*/
9394
EXCEPTION {
9495
@Override

spring-web/src/main/java/org/springframework/http/observation/reactive/DefaultServerRequestObservationConvention.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class DefaultServerRequestObservationConvention implements ServerRequestO
5050

5151
private static final KeyValue URI_REDIRECTION = KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.URI, "REDIRECTION");
5252

53-
private static final KeyValue EXCEPTION_NONE = KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.EXCEPTION, "none");
53+
private static final KeyValue EXCEPTION_NONE = KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.EXCEPTION, KeyValue.NONE_VALUE);
5454

5555
private static final KeyValue HTTP_URL_UNKNOWN = KeyValue.of(ServerHttpObservationDocumentation.HighCardinalityKeyNames.HTTP_URL, "UNKNOWN");
5656

spring-web/src/main/java/org/springframework/http/observation/reactive/ServerHttpObservationDocumentation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.http.observation.reactive;
1818

19+
import io.micrometer.common.KeyValue;
1920
import io.micrometer.common.docs.KeyName;
2021
import io.micrometer.observation.Observation;
2122
import io.micrometer.observation.ObservationConvention;
@@ -55,7 +56,7 @@ public KeyName[] getHighCardinalityKeyNames() {
5556
public enum LowCardinalityKeyNames implements KeyName {
5657

5758
/**
58-
* Name of HTTP request method or {@code "none"} if the request was not received properly.
59+
* Name of HTTP request method or {@value KeyValue#NONE_VALUE} if the request was not received properly.
5960
*/
6061
METHOD {
6162
@Override
@@ -88,7 +89,7 @@ public String asString() {
8889
},
8990

9091
/**
91-
* Name of the exception thrown during the exchange, or {@code "none"} if no exception happened.
92+
* Name of the exception thrown during the exchange, or {@value KeyValue#NONE_VALUE} if no exception happened.
9293
*/
9394
EXCEPTION {
9495
@Override

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientHttpObservationDocumentation.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.web.reactive.function.client;
1818

19+
import io.micrometer.common.KeyValue;
1920
import io.micrometer.common.docs.KeyName;
2021
import io.micrometer.observation.Observation;
2122
import io.micrometer.observation.ObservationConvention;
@@ -54,7 +55,7 @@ public KeyName[] getHighCardinalityKeyNames() {
5455
public enum LowCardinalityKeyNames implements KeyName {
5556

5657
/**
57-
* Name of HTTP request method or {@code "none"} if the request could not be created.
58+
* Name of HTTP request method or {@value KeyValue#NONE_VALUE} if the request could not be created.
5859
*/
5960
METHOD {
6061
@Override
@@ -65,7 +66,7 @@ public String asString() {
6566
},
6667

6768
/**
68-
* URI template used for HTTP request, or {@code "none"} if none was provided.
69+
* URI template used for HTTP request, or {@value KeyValue#NONE_VALUE} if none was provided.
6970
*/
7071
URI {
7172
@Override
@@ -86,7 +87,7 @@ public String asString() {
8687
},
8788

8889
/**
89-
* Name of the exception thrown during the exchange, or {@code "none"} if no exception happened.
90+
* Name of the exception thrown during the exchange, or {@value KeyValue#NONE_VALUE} if no exception happened.
9091
*/
9192
EXCEPTION {
9293
@Override

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestObservationConvention.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
3636

3737
private static final String DEFAULT_NAME = "http.client.requests";
3838

39-
private static final KeyValue URI_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.URI, "none");
39+
private static final KeyValue URI_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.URI, KeyValue.NONE_VALUE);
4040

41-
private static final KeyValue METHOD_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.METHOD, "none");
41+
private static final KeyValue METHOD_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.METHOD, KeyValue.NONE_VALUE);
4242

4343
private static final KeyValue STATUS_IO_ERROR = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.STATUS, "IO_ERROR");
4444

@@ -48,11 +48,11 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
4848

4949
private static final KeyValue HTTP_OUTCOME_UNKNOWN = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.OUTCOME, "UNKNOWN");
5050

51-
private static final KeyValue EXCEPTION_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.EXCEPTION, "none");
51+
private static final KeyValue EXCEPTION_NONE = KeyValue.of(ClientHttpObservationDocumentation.LowCardinalityKeyNames.EXCEPTION, KeyValue.NONE_VALUE);
5252

53-
private static final KeyValue HTTP_URL_NONE = KeyValue.of(ClientHttpObservationDocumentation.HighCardinalityKeyNames.HTTP_URL, "none");
53+
private static final KeyValue HTTP_URL_NONE = KeyValue.of(ClientHttpObservationDocumentation.HighCardinalityKeyNames.HTTP_URL, KeyValue.NONE_VALUE);
5454

55-
private static final KeyValue CLIENT_NAME_NONE = KeyValue.of(ClientHttpObservationDocumentation.HighCardinalityKeyNames.CLIENT_NAME, "none");
55+
private static final KeyValue CLIENT_NAME_NONE = KeyValue.of(ClientHttpObservationDocumentation.HighCardinalityKeyNames.CLIENT_NAME, KeyValue.NONE_VALUE);
5656

5757
private final String name;
5858

0 commit comments

Comments
 (0)