diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClient9TracingInterceptor.java b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClient9TracingInterceptor.java index e5c030986c94..3c45ce65278d 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClient9TracingInterceptor.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClient9TracingInterceptor.java @@ -136,7 +136,9 @@ public void onBegin(Request request) { if (this.context != null) { Span span = Span.fromContext(this.context); HttpField agentField = request.getHeaders().getField(HttpHeader.USER_AGENT); - span.setAttribute(SemanticAttributes.HTTP_USER_AGENT, agentField.getValue()); + if (agentField != null) { + span.setAttribute(SemanticAttributes.HTTP_USER_AGENT, agentField.getValue()); + } } }