reta commented on code in PR #2062:
URL: https://github.com/apache/cxf/pull/2062#discussion_r1757601395


##########
integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/OpenTelemetryStartInterceptor.java:
##########
@@ -51,5 +56,19 @@ public void handleMessage(Message message) throws Fault {
         if (holder != null) {
             message.getExchange().put(TRACE_SPAN, holder);
         }
+
+        HttpServletRequest request = 
(HttpServletRequest)message.getContextualProperty("HTTP.REQUEST");
+        if (request != null) {
+            Span.current().setAttribute(ClientAttributes.CLIENT_ADDRESS, 
request.getRemoteAddr());
+            Span.current().setAttribute(ClientAttributes.CLIENT_PORT, 
request.getRemotePort());
+            
Span.current().setAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, 
request.getRemoteAddr());
+            Span.current().setAttribute(NetworkAttributes.NETWORK_PEER_PORT, 
request.getRemotePort());
+            String protocol = request.getProtocol();
+            if (protocol != null && protocol.contains("/")) {
+                String protocolVersion = protocol.split("/")[1];
+                
Span.current().setAttribute(NetworkAttributes.NETWORK_PROTOCOL_VERSION, 
protocolVersion);
+            }
+            
Span.current().setAttribute(UserAgentAttributes.USER_AGENT_ORIGINAL, 
request.getHeader("User-Agent"));

Review Comment:
   Probably better to check if the `request.getHeader("User-Agent")` is not 
null?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to