Skip to content

Commit 94d1787

Browse files
iNikemRashmiRam
authored andcommitted
Prevent NPE (open-telemetry#4527)
1 parent f9a19d4 commit 94d1787

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClient9TracingInterceptor.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ public void onBegin(Request request) {
136136
if (this.context != null) {
137137
Span span = Span.fromContext(this.context);
138138
HttpField agentField = request.getHeaders().getField(HttpHeader.USER_AGENT);
139-
span.setAttribute(SemanticAttributes.HTTP_USER_AGENT, agentField.getValue());
139+
if (agentField != null) {
140+
span.setAttribute(SemanticAttributes.HTTP_USER_AGENT, agentField.getValue());
141+
}
140142
}
141143
}
142144

0 commit comments

Comments
 (0)