Skip to content

Commit

Permalink
Prevent NPE (open-telemetry#4527)
Browse files Browse the repository at this point in the history
  • Loading branch information
iNikem authored and RashmiRam committed May 23, 2022
1 parent f9a19d4 commit 94d1787
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

Expand Down

0 comments on commit 94d1787

Please sign in to comment.