88import datadog .trace .bootstrap .instrumentation .api .ResourceNamePriorities ;
99import datadog .trace .bootstrap .instrumentation .api .UTF8BytesString ;
1010import java .util .function .Function ;
11+ import javax .annotation .Nonnull ;
1112
1213public class HttpResourceNames {
1314 public static final UTF8BytesString DEFAULT_RESOURCE_NAME = UTF8BytesString .create ("/" );
@@ -71,6 +72,9 @@ private HttpResourceNames() {
7172
7273 public static AgentSpan setForServer (
7374 AgentSpan span , CharSequence method , CharSequence path , boolean encoded ) {
75+ if (path == null ) {
76+ return span ;
77+ }
7478 Pair <CharSequence , Byte > result = computeForServer (method , path , encoded );
7579 if (result .hasLeft ()) {
7680 span .setResourceName (result .getLeft (), result .getRight ());
@@ -80,7 +84,7 @@ public static AgentSpan setForServer(
8084 }
8185
8286 public static Pair <CharSequence , Byte > computeForServer (
83- CharSequence method , CharSequence path , boolean encoded ) {
87+ CharSequence method , @ Nonnull CharSequence path , boolean encoded ) {
8488 byte priority ;
8589
8690 String resourcePath =
@@ -96,7 +100,7 @@ public static Pair<CharSequence, Byte> computeForServer(
96100 }
97101
98102 public static Pair <CharSequence , Byte > computeForClient (
99- CharSequence method , CharSequence path , boolean encoded ) {
103+ CharSequence method , @ Nonnull CharSequence path , boolean encoded ) {
100104 byte priority ;
101105
102106 String resourcePath =
@@ -112,6 +116,9 @@ public static Pair<CharSequence, Byte> computeForClient(
112116
113117 public static AgentSpan setForClient (
114118 AgentSpan span , CharSequence method , CharSequence path , boolean encoded ) {
119+ if (path == null ) {
120+ return span ;
121+ }
115122 Pair <CharSequence , Byte > result = computeForClient (method , path , encoded );
116123 if (result .hasLeft ()) {
117124 span .setResourceName (result .getLeft (), result .getRight ());
0 commit comments