@@ -39,7 +39,10 @@ public final class TracingUtils {
39
39
* @param value the value of the annotation
40
40
*/
41
41
public static void putAnnotation (String key , String value ) {
42
- validateAnnotationKey (key );
42
+ if (!isValidateAnnotationKey (key )) {
43
+ LOG .warn ("Ignoring annotation with unsupported characters in key: {}" , key );
44
+ return ;
45
+ }
43
46
AWSXRay .getCurrentSubsegmentOptional ()
44
47
.ifPresent (segment -> segment .putAnnotation (key , value ));
45
48
}
@@ -51,15 +54,22 @@ public static void putAnnotation(String key, String value) {
51
54
* @param value the value of the annotation
52
55
*/
53
56
public static void putAnnotation (String key , Number value ) {
54
- validateAnnotationKey (key );
57
+ if (!isValidateAnnotationKey (key )) {
58
+ LOG .warn ("Ignoring annotation with unsupported characters in key: {}" , key );
59
+ return ;
60
+ }
55
61
AWSXRay .getCurrentSubsegmentOptional ()
56
62
.ifPresent (segment -> segment .putAnnotation (key , value ));
57
63
}
58
64
59
- private static void validateAnnotationKey (String key ) {
60
- if (!key .matches ("^[a-zA-Z0-9_]+$" )) {
61
- LOG .warn ("ignoring annotation with unsupported characters in key: {}" , key );
62
- }
65
+ /**
66
+ Make sure that the annotation key is valid according to
67
+ <a href='https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-annotations'>the documentation</a>.
68
+
69
+ Annotation keys that are added that are invalid are ignored by x-ray.
70
+ **/
71
+ private static boolean isValidateAnnotationKey (String key ) {
72
+ return key .matches ("^[a-zA-Z0-9_]+$" );
63
73
}
64
74
65
75
/**
0 commit comments