You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2024/09/13 23:15:13 UTC

(cxf) branch 4.0.x-fixes updated (25adc2a4aa -> ab0a279f62)

This is an automated email from the ASF dual-hosted git repository.

reta pushed a change to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


    from 25adc2a4aa Recording .gitmergeinfo Changes
     new 821679342c Bump org.jboss.logging:jboss-logging from 3.6.0.Final to 3.6.1.Final (#2064)
     new 9be16406ce CXF-9055 Follow OpenTelemetry semconv for trace span and its attributes (#2062)
     new 5215981078 CXF-9055: Follow OpenTelemetry semconv for trace span and its attributes (minor code cleanups)
     new ab0a279f62 Recording .gitmergeinfo Changes

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                      |   3 +
 integration/tracing/tracing-opentelemetry/pom.xml  |   5 +
 .../AbstractOpenTelemetryClientProvider.java       |  31 ++++--
 .../AbstractOpenTelemetryProvider.java             |  21 +++-
 .../OpenTelemetryStartInterceptor.java             |  25 +++++
 .../opentelemetry/jaxrs/OpenTelemetryProvider.java |  34 +++++-
 parent/pom.xml                                     |   2 +-
 .../opentelemetry/OpenTelemetryTracingTest.java    | 116 ++++++++++++++++++---
 .../opentelemetry/OpenTelemetryTracingTest.java    |  93 ++++++++++++++---
 9 files changed, 286 insertions(+), 44 deletions(-)


(cxf) 02/04: CXF-9055 Follow OpenTelemetry semconv for trace span and its attributes (#2062)

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 9be16406ce3ccda7468323e539dbe00ef22f781d
Author: Christian Semaan <15...@users.noreply.github.com>
AuthorDate: Fri Sep 13 23:26:25 2024 +0200

    CXF-9055 Follow OpenTelemetry semconv for trace span and its attributes (#2062)
    
    * Add missing span attributes to comply with [OpenTelemetry semantic conventions](https://opentelemetry.io/docs/specs/semconv/http/http-spans/)
    * Test the span attribute names and values
    * Couldn't add the attributes "network.protocol.version" for the client http span, because we didn't find a way to find its value.
    
    Link to the Jira ticket: [CXF-9055 Follow OpenTelemetry semantic conventions for trace span and its attributes
    ](https://issues.apache.org/jira/browse/CXF-9055)
    
    (cherry picked from commit 1f0355e72b695b42fdbe9d15fb4713ee7c92df90)
---
 integration/tracing/tracing-opentelemetry/pom.xml  |   5 +
 .../AbstractOpenTelemetryClientProvider.java       |  31 ++++--
 .../AbstractOpenTelemetryProvider.java             |  21 +++-
 .../OpenTelemetryStartInterceptor.java             |  24 +++++
 .../opentelemetry/jaxrs/OpenTelemetryProvider.java |  30 +++++-
 .../opentelemetry/OpenTelemetryTracingTest.java    | 116 ++++++++++++++++++---
 .../opentelemetry/OpenTelemetryTracingTest.java    |  93 ++++++++++++++---
 7 files changed, 277 insertions(+), 43 deletions(-)

diff --git a/integration/tracing/tracing-opentelemetry/pom.xml b/integration/tracing/tracing-opentelemetry/pom.xml
index 05252eb7a6..6f4f1784da 100644
--- a/integration/tracing/tracing-opentelemetry/pom.xml
+++ b/integration/tracing/tracing-opentelemetry/pom.xml
@@ -46,6 +46,11 @@
             <artifactId>jakarta.xml.ws-api</artifactId>
             <optional>true</optional>
         </dependency>
+        <dependency>
+            <groupId>jakarta.servlet</groupId>
+            <artifactId>jakarta.servlet-api</artifactId>
+            <optional>true</optional>
+        </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
diff --git a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/AbstractOpenTelemetryClientProvider.java b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/AbstractOpenTelemetryClientProvider.java
index 2ffde203b1..486970375e 100644
--- a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/AbstractOpenTelemetryClientProvider.java
+++ b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/AbstractOpenTelemetryClientProvider.java
@@ -36,9 +36,12 @@ import io.opentelemetry.api.trace.StatusCode;
 import io.opentelemetry.api.trace.Tracer;
 import io.opentelemetry.context.Context;
 import io.opentelemetry.context.Scope;
+import io.opentelemetry.semconv.ErrorAttributes;
+import io.opentelemetry.semconv.ExceptionAttributes;
 import io.opentelemetry.semconv.HttpAttributes;
+import io.opentelemetry.semconv.NetworkAttributes;
+import io.opentelemetry.semconv.ServerAttributes;
 import io.opentelemetry.semconv.UrlAttributes;
-import io.opentelemetry.semconv.incubating.ExceptionIncubatingAttributes;
 
 public abstract class AbstractOpenTelemetryClientProvider extends AbstractTracingProvider {
     protected static final Logger LOG = LogUtils.getL7dLogger(AbstractOpenTelemetryClientProvider.class);
@@ -60,11 +63,14 @@ public abstract class AbstractOpenTelemetryClientProvider extends AbstractTracin
                                                           URI uri, String method) {
         Context parentContext = Context.current();
         Span activeSpan = tracer.spanBuilder(buildSpanDescription(uri.toString(), method))
-            .setParent(parentContext).setSpanKind(SpanKind.CLIENT)
-            .setAttribute(HttpAttributes.HTTP_REQUEST_METHOD, method)
-            .setAttribute(UrlAttributes.URL_FULL, uri.toString())
-            // TODO: Enhance with semantics from request
-            .startSpan();
+                .setParent(parentContext).setSpanKind(SpanKind.CLIENT)
+                .setAttribute(HttpAttributes.HTTP_REQUEST_METHOD, method)
+                .setAttribute(ServerAttributes.SERVER_ADDRESS, uri.getHost())
+                .setAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(uri.getPort()))
+                .setAttribute(UrlAttributes.URL_FULL, uri.toString())
+                .setAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, uri.getHost())
+                .setAttribute(NetworkAttributes.NETWORK_PEER_PORT, Long.valueOf(uri.getPort()))
+                .startSpan();
         Scope scope = activeSpan.makeCurrent();
 
         openTelemetry.getPropagators().getTextMapPropagator().inject(Context.current(), requestHeaders,
@@ -96,12 +102,19 @@ public abstract class AbstractOpenTelemetryClientProvider extends AbstractTracin
             Span span = traceScope.getSpan();
             Scope scope = traceScope.getScope();
 
-            // If the client invocation was asynchronous , the trace span has been created
+            // If the client invocation was asynchronous, the trace span has been created
             // in another thread and should be re-attached to the current one.
             if (holder.isDetached()) {
                 scope = span.makeCurrent();
             }
 
+            // Check if the response status code starts with 3, 4, or 5 (indicating redirection,
+            // client error, or server error)
+            // If true, set the error type attribute on the span with the response status code
+            if (responseStatus >= 300) {
+                span.setAttribute(ErrorAttributes.ERROR_TYPE, String.valueOf(responseStatus));
+            }
+
             span.setAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE.getKey(), responseStatus);
 
             span.end();
@@ -120,7 +133,7 @@ public abstract class AbstractOpenTelemetryClientProvider extends AbstractTracin
             Span span = traceScope.getSpan();
             Scope scope = traceScope.getScope();
 
-            // If the client invocation was asynchronous , the trace span has been created
+            // If the client invocation was asynchronous, the trace span has been created
             // in another thread and should be re-attached to the current one.
             if (holder.isDetached()) {
                 scope = span.makeCurrent();
@@ -128,7 +141,7 @@ public abstract class AbstractOpenTelemetryClientProvider extends AbstractTracin
 
             span.setStatus(StatusCode.ERROR);
             if (ex != null) {
-                span.recordException(ex, Attributes.of(ExceptionIncubatingAttributes.EXCEPTION_ESCAPED, true));
+                span.recordException(ex, Attributes.of(ExceptionAttributes.EXCEPTION_ESCAPED, true));
             }
             span.end();
 
diff --git a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/AbstractOpenTelemetryProvider.java b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/AbstractOpenTelemetryProvider.java
index d9b7d6e2ce..d95ed00c36 100644
--- a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/AbstractOpenTelemetryProvider.java
+++ b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/AbstractOpenTelemetryProvider.java
@@ -35,7 +35,9 @@ import io.opentelemetry.api.trace.SpanKind;
 import io.opentelemetry.api.trace.Tracer;
 import io.opentelemetry.context.Context;
 import io.opentelemetry.context.Scope;
+import io.opentelemetry.semconv.ErrorAttributes;
 import io.opentelemetry.semconv.HttpAttributes;
+import io.opentelemetry.semconv.ServerAttributes;
 import io.opentelemetry.semconv.UrlAttributes;
 
 public abstract class AbstractOpenTelemetryProvider extends AbstractTracingProvider {
@@ -65,12 +67,18 @@ public abstract class AbstractOpenTelemetryProvider extends AbstractTracingProvi
         SpanBuilder spanBuilder = tracer.spanBuilder(buildSpanDescription(uri.getPath(), method))
             .setSpanKind(SpanKind.SERVER)
             .setAttribute(HttpAttributes.HTTP_REQUEST_METHOD, method)
-            .setAttribute(UrlAttributes.URL_FULL, uri.toString());
+            .setAttribute(UrlAttributes.URL_PATH, uri.getPath())
+            .setAttribute(UrlAttributes.URL_SCHEME, uri.getScheme())
+            .setAttribute(ServerAttributes.SERVER_ADDRESS, uri.getHost())
+            .setAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(uri.getPort()));
+
+        if (uri.getQuery() != null) {
+            spanBuilder.setAttribute(UrlAttributes.URL_QUERY, uri.getQuery());
+        }
+
         Span activeSpan = spanBuilder.startSpan();
         Scope scope = activeSpan.makeCurrent();
 
-        // Set additional tags
-
         // If the service resource is using asynchronous processing mode, the trace
         // scope will be closed in another thread and as such should be detached.
         Span span = null;
@@ -105,6 +113,13 @@ public abstract class AbstractOpenTelemetryProvider extends AbstractTracingProvi
                 scope = span.makeCurrent();
             }
 
+            // Check if the response status code starts with 3, 4, or 5 (indicating redirection,
+            // client error, or server error)
+            // If true, set the error type attribute on the span with the response status code
+            if (responseStatus >= 300) {
+                span.setAttribute(ErrorAttributes.ERROR_TYPE, String.valueOf(responseStatus));
+            }
+
             span.setAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, responseStatus);
             span.end();
 
diff --git a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/OpenTelemetryStartInterceptor.java b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/OpenTelemetryStartInterceptor.java
index 24f2a63fc7..d7aa118cc4 100644
--- a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/OpenTelemetryStartInterceptor.java
+++ b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/OpenTelemetryStartInterceptor.java
@@ -21,14 +21,20 @@ package org.apache.cxf.tracing.opentelemetry;
 import java.util.List;
 import java.util.Map;
 
+import jakarta.servlet.http.HttpServletRequest;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
 
 import io.opentelemetry.api.OpenTelemetry;
+import io.opentelemetry.api.trace.Span;
 import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.semconv.ClientAttributes;
+import io.opentelemetry.semconv.NetworkAttributes;
+import io.opentelemetry.semconv.UserAgentAttributes;
 
 @NoJSR250Annotations
 public class OpenTelemetryStartInterceptor extends AbstractOpenTelemetryInterceptor {
@@ -51,5 +57,23 @@ public class OpenTelemetryStartInterceptor extends AbstractOpenTelemetryIntercep
         if (holder != null) {
             message.getExchange().put(TRACE_SPAN, holder);
         }
+
+        HttpServletRequest request = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
+        if (request != null) {
+            Span span = holder.getScope().getSpan();
+            span.setAttribute(ClientAttributes.CLIENT_ADDRESS, request.getRemoteAddr());
+            span.setAttribute(ClientAttributes.CLIENT_PORT, request.getRemotePort());
+            span.setAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, request.getRemoteAddr());
+            span.setAttribute(NetworkAttributes.NETWORK_PEER_PORT, request.getRemotePort());
+            String protocol = request.getProtocol();
+            if (protocol != null && protocol.contains("/")) {
+                String protocolVersion = protocol.split("/")[1];
+                span.setAttribute(NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
+            }
+
+            if (request.getHeader("User-Agent") != null) {
+                span.setAttribute(UserAgentAttributes.USER_AGENT_ORIGINAL, request.getHeader("User-Agent"));
+            }
+        }
     }
 }
diff --git a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/jaxrs/OpenTelemetryProvider.java b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/jaxrs/OpenTelemetryProvider.java
index 4523a57c21..4b8759fdf9 100644
--- a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/jaxrs/OpenTelemetryProvider.java
+++ b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/jaxrs/OpenTelemetryProvider.java
@@ -21,6 +21,7 @@ package org.apache.cxf.tracing.opentelemetry.jaxrs;
 import java.io.IOException;
 import java.lang.annotation.Annotation;
 
+import jakarta.servlet.http.HttpServletRequest;
 import jakarta.ws.rs.container.ContainerRequestContext;
 import jakarta.ws.rs.container.ContainerRequestFilter;
 import jakarta.ws.rs.container.ContainerResponseContext;
@@ -33,7 +34,11 @@ import org.apache.cxf.tracing.opentelemetry.AbstractOpenTelemetryProvider;
 import org.apache.cxf.tracing.opentelemetry.TraceScope;
 
 import io.opentelemetry.api.OpenTelemetry;
+import io.opentelemetry.api.trace.Span;
 import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.semconv.ClientAttributes;
+import io.opentelemetry.semconv.NetworkAttributes;
+import io.opentelemetry.semconv.UserAgentAttributes;
 
 @Provider
 public class OpenTelemetryProvider extends AbstractOpenTelemetryProvider
@@ -41,6 +46,9 @@ public class OpenTelemetryProvider extends AbstractOpenTelemetryProvider
     @Context
     private ResourceInfo resourceInfo;
 
+    @Context
+    private HttpServletRequest request;
+
     public OpenTelemetryProvider(final OpenTelemetry openTelemetry, final String instrumentationName) {
         super(openTelemetry, instrumentationName);
     }
@@ -52,10 +60,25 @@ public class OpenTelemetryProvider extends AbstractOpenTelemetryProvider
     @Override
     public void filter(final ContainerRequestContext requestContext) throws IOException {
         final TraceScopeHolder<TraceScope> holder = super.startTraceSpan(requestContext.getHeaders(),
-                                                                         requestContext.getUriInfo()
-                                                                             .getRequestUri(),
+                                                                         requestContext.getUriInfo().getRequestUri(),
                                                                          requestContext.getMethod());
 
+
+
+        if (request != null) {
+            Span span = holder.getScope().getSpan();
+            span.setAttribute(ClientAttributes.CLIENT_ADDRESS, request.getRemoteAddr());
+            span.setAttribute(ClientAttributes.CLIENT_PORT, request.getRemotePort());
+            span.setAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, request.getRemoteAddr());
+            span.setAttribute(NetworkAttributes.NETWORK_PEER_PORT, request.getRemotePort());
+            String protocol = request.getProtocol();
+            if (protocol != null && protocol.contains("/")) {
+                String protocolVersion = protocol.split("/")[1];
+                span.setAttribute(NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
+            }
+            span.setAttribute(UserAgentAttributes.USER_AGENT_ORIGINAL, request.getHeader("User-Agent"));
+        }
+
         if (holder != null) {
             requestContext.setProperty(TRACE_SPAN, holder);
         }
@@ -64,8 +87,7 @@ public class OpenTelemetryProvider extends AbstractOpenTelemetryProvider
     @SuppressWarnings("unchecked")
     @Override
     public void filter(final ContainerRequestContext requestContext,
-                       final ContainerResponseContext responseContext)
-        throws IOException {
+                       final ContainerResponseContext responseContext) {
         super.stopTraceSpan(requestContext.getHeaders(), responseContext.getHeaders(),
                             responseContext.getStatus(),
                             (TraceScopeHolder<TraceScope>)requestContext.getProperty(TRACE_SPAN));
diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentelemetry/OpenTelemetryTracingTest.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentelemetry/OpenTelemetryTracingTest.java
index e2cc6278be..e90c2796b3 100644
--- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentelemetry/OpenTelemetryTracingTest.java
+++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentelemetry/OpenTelemetryTracingTest.java
@@ -61,7 +61,14 @@ import io.opentelemetry.context.Context;
 import io.opentelemetry.context.Scope;
 import io.opentelemetry.context.propagation.TextMapSetter;
 import io.opentelemetry.sdk.testing.junit4.OpenTelemetryRule;
+import io.opentelemetry.sdk.trace.data.SpanData;
+import io.opentelemetry.semconv.ClientAttributes;
+import io.opentelemetry.semconv.ErrorAttributes;
 import io.opentelemetry.semconv.HttpAttributes;
+import io.opentelemetry.semconv.NetworkAttributes;
+import io.opentelemetry.semconv.ServerAttributes;
+import io.opentelemetry.semconv.UrlAttributes;
+import io.opentelemetry.semconv.UserAgentAttributes;
 
 import org.junit.After;
 import org.junit.BeforeClass;
@@ -74,10 +81,12 @@ import static org.apache.cxf.systest.jaxrs.tracing.opentelemetry.HasAttribute.ha
 import static org.apache.cxf.systest.jaxrs.tracing.opentelemetry.HasSpan.hasSpan;
 import static org.apache.cxf.systest.jaxrs.tracing.opentelemetry.IsLogContaining.hasItem;
 import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
@@ -92,7 +101,7 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
     public ExpectedException expectedException = ExpectedException.none();
 
     @BeforeClass
-    public static void startServers() throws Exception {
+    public static void startServers() {
         AbstractResourceInfo.clearAllMaps();
         // keep out of process due to stack traces testing failures
         assertTrue("server did not launch correctly", launchServer(OpenTelemetryServer.class, true));
@@ -123,11 +132,23 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
 
         assertThat(otelRule.getSpans().size(), equalTo(2));
         assertThat(otelRule.getSpans().get(0).getName(), equalTo("Get Books"));
-        assertThat(otelRule.getSpans().get(1).getName(), equalTo("GET /bookstore/books"));
-        assertThat(otelRule.getSpans().get(1).getAttributes(),
-                   hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
-        assertThat(otelRule.getSpans().get(1).getInstrumentationScopeInfo().getName(),
-            equalTo("jaxrs-server-test"));
+        SpanData serverSpan = otelRule.getSpans().get(1);
+        assertThat(serverSpan.getName(), equalTo("GET /bookstore/books"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD, "GET"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(UrlAttributes.URL_PATH, "/bookstore/books"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_ADDRESS, "localhost"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(PORT)));
+        assertThat(serverSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"));
+        assertNotNull(serverSpan.getAttributes().get(NetworkAttributes.NETWORK_PEER_PORT));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ClientAttributes.CLIENT_ADDRESS, "127.0.0.1"));
+        assertNotNull(serverSpan.getAttributes().get(ClientAttributes.CLIENT_PORT));
+        assertThat(serverSpan.getAttributes(), hasAttribute(UrlAttributes.URL_SCHEME, "http"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"));
+        String userAgent = serverSpan.getAttributes().get(UserAgentAttributes.USER_AGENT_ORIGINAL);
+        assertNotNull(userAgent);
+        assertThat(userAgent, containsString("Apache-CXF/"));
+        assertThat(serverSpan.getInstrumentationScopeInfo().getName(), equalTo("jaxrs-server-test"));
     }
 
     @Test
@@ -187,6 +208,45 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
         assertThat(otelRule.getSpans().get(2).getInstrumentationScopeInfo().getName(), equalTo("jaxrs-client-test"));
     }
 
+    @Test
+    public void spanShouldHasRequiredAttributes() {
+        final Response r = createWebClient("/bookstore/books",
+                new OpenTelemetryClientProvider(otelRule.getOpenTelemetry(), "jaxrs-client-test"))
+                .get();
+        assertEquals(Status.OK.getStatusCode(), r.getStatus());
+
+        assertThat(otelRule.getSpans().toString(), otelRule.getSpans().size(), equalTo(3));
+
+        SpanData clientSpan = otelRule.getSpans().get(2);
+        assertThat(clientSpan.getName(), equalTo("GET http://localhost:" + PORT + "/bookstore/books"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
+        assertThat(clientSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD, "GET"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(UrlAttributes.URL_FULL,
+                "http://localhost:" + PORT + "/bookstore/books"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_ADDRESS, "localhost"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(PORT)));
+        assertThat(clientSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, "localhost"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_PORT, Long.valueOf(PORT)));
+
+        SpanData serverSpan = otelRule.getSpans().get(1);
+        assertThat(serverSpan.getName(), equalTo("GET /bookstore/books"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD, "GET"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(UrlAttributes.URL_PATH, "/bookstore/books"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_ADDRESS, "localhost"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(PORT)));
+        assertThat(serverSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"));
+        assertNotNull(serverSpan.getAttributes().get(NetworkAttributes.NETWORK_PEER_PORT));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ClientAttributes.CLIENT_ADDRESS, "127.0.0.1"));
+        assertNotNull(serverSpan.getAttributes().get(ClientAttributes.CLIENT_PORT));
+        assertThat(serverSpan.getAttributes(), hasAttribute(UrlAttributes.URL_SCHEME, "http"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"));
+        String userAgent = serverSpan.getAttributes().get(UserAgentAttributes.USER_AGENT_ORIGINAL);
+        assertNotNull(userAgent);
+        assertThat(userAgent, containsString("Apache-CXF/"));
+        assertThat(serverSpan.getInstrumentationScopeInfo().getName(), equalTo("jaxrs-server-test"));
+    }
+
     @Test
     public void testThatNewInnerSpanIsCreatedUsingAsyncInvocation() throws InterruptedException {
         final Context parentContext = fromRandom();
@@ -254,7 +314,7 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
         final WebClient client = createWebClient("/bookstore/books",
             new OpenTelemetryClientProvider(otelRule.getOpenTelemetry(), "jaxrs-client-test"));
 
-        // The intention is to make a calls one after another, not in parallel, to ensure the
+        // The intention is to make multiple calls one after another, not in parallel, to ensure the
         // thread have trace contexts cleared out.
         IntStream.range(0, 4).mapToObj(index -> client.async().get()).map(this::get)
             .forEach(r -> assertEquals(Status.OK.getStatusCode(), r.getStatus()));
@@ -264,8 +324,7 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
         IntStream.range(0, 4).map(index -> index * 3).forEach(index -> {
             assertThat(otelRule.getSpans().get(index).getName(), equalTo("Get Books"));
             assertThat(otelRule.getSpans().get(index + 1).getName(), equalTo("GET /bookstore/books"));
-            assertThat(otelRule.getSpans().get(index + 2).getName(),
-                       equalTo("GET " + client.getCurrentURI()));
+            assertThat(otelRule.getSpans().get(index + 2).getName(), equalTo("GET " + client.getCurrentURI()));
         });
     }
 
@@ -274,7 +333,7 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
         final WebClient client = createWebClient("/bookstore/books",
             new OpenTelemetryClientProvider(otelRule.getOpenTelemetry(), "jaxrs-client-test"));
 
-        // The intention is to make a calls one after another, not in parallel, to ensure the
+        // The intention is to make multiple calls one after another, not in parallel, to ensure the
         // thread have trace contexts cleared out.
         IntStream.range(0, 4).mapToObj(index -> client.get())
             .forEach(r -> assertEquals(Status.OK.getStatusCode(), r.getStatus()));
@@ -284,8 +343,7 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
         IntStream.range(0, 4).map(index -> index * 3).forEach(index -> {
             assertThat(otelRule.getSpans().get(index).getName(), equalTo("Get Books"));
             assertThat(otelRule.getSpans().get(index + 1).getName(), equalTo("GET /bookstore/books"));
-            assertThat(otelRule.getSpans().get(index + 2).getName(),
-                       equalTo("GET " + client.getCurrentURI()));
+            assertThat(otelRule.getSpans().get(index + 2).getName(), equalTo("GET " + client.getCurrentURI()));
         });
     }
 
@@ -395,9 +453,37 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
         assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
 
         assertThat(otelRule.getSpans().toString(), otelRule.getSpans().size(), equalTo(1));
-        assertThat(otelRule.getSpans().get(0).getName(), equalTo("GET /bookstore/books/exception"));
-        assertThat(otelRule.getSpans().get(0).getAttributes(),
-                   hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500L));
+        SpanData serverSpan = otelRule.getSpans().get(0);
+
+        assertThat(serverSpan.getName(), equalTo("GET /bookstore/books/exception"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500L));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD, "GET"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(UrlAttributes.URL_PATH, "/bookstore/books/exception"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_ADDRESS, "localhost"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(PORT)));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ErrorAttributes.ERROR_TYPE,  String.valueOf(500)));
+    }
+
+    @Test
+    public void testClientSpanAttributesOnException() {
+        final Response r = createWebClient("/bookstore/books/exception",
+                new OpenTelemetryClientProvider(otelRule.getOpenTelemetry(), "jaxrs-client-test"))
+                .get();
+
+        assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
+
+        assertThat(otelRule.getSpans().toString(), otelRule.getSpans().size(), equalTo(2));
+
+        SpanData clientSpan = otelRule.getSpans().get(1);
+        assertThat(clientSpan.getName(), equalTo("GET http://localhost:" + PORT + "/bookstore/books/exception"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD, "GET"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(UrlAttributes.URL_FULL,
+                "http://localhost:" + PORT + "/bookstore/books/exception"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_ADDRESS, "localhost"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(PORT)));
+        assertThat(clientSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, "localhost"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_PORT, Long.valueOf(PORT)));
+        assertThat(clientSpan.getAttributes(), hasAttribute(ErrorAttributes.ERROR_TYPE,  String.valueOf(500)));
     }
 
     @Test
diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/OpenTelemetryTracingTest.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/OpenTelemetryTracingTest.java
index f3e500dcc1..71a9f499e2 100644
--- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/OpenTelemetryTracingTest.java
+++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/OpenTelemetryTracingTest.java
@@ -52,7 +52,14 @@ import io.opentelemetry.api.trace.TraceState;
 import io.opentelemetry.context.Context;
 import io.opentelemetry.context.Scope;
 import io.opentelemetry.sdk.testing.junit4.OpenTelemetryRule;
+import io.opentelemetry.sdk.trace.data.SpanData;
+import io.opentelemetry.semconv.ClientAttributes;
+import io.opentelemetry.semconv.ErrorAttributes;
 import io.opentelemetry.semconv.HttpAttributes;
+import io.opentelemetry.semconv.NetworkAttributes;
+import io.opentelemetry.semconv.ServerAttributes;
+import io.opentelemetry.semconv.UrlAttributes;
+import io.opentelemetry.semconv.UserAgentAttributes;
 
 import org.junit.After;
 import org.junit.BeforeClass;
@@ -61,10 +68,12 @@ import org.junit.Test;
 
 import static org.apache.cxf.systest.jaxrs.tracing.opentelemetry.HasAttribute.hasAttribute;
 import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -131,7 +140,24 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
 
         assertThat(otelRule.getSpans().size(), equalTo(2));
         assertThat(otelRule.getSpans().get(0).getName(), equalTo("Get Books"));
-        assertThat(otelRule.getSpans().get(1).getName(), equalTo("POST /BookStore"));
+
+        SpanData serverSpan = otelRule.getSpans().get(1);
+        assertThat(serverSpan.getName(), equalTo("POST /BookStore"));
+        assertThat(serverSpan.getKind(), equalTo(SpanKind.SERVER));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD, "POST"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(UrlAttributes.URL_PATH, "/BookStore"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_ADDRESS, "localhost"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(PORT)));
+        assertThat(serverSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"));
+        assertNotNull(serverSpan.getAttributes().get(NetworkAttributes.NETWORK_PEER_PORT));
+        assertThat(serverSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ClientAttributes.CLIENT_ADDRESS, "127.0.0.1"));
+        assertNotNull(serverSpan.getAttributes().get(ClientAttributes.CLIENT_PORT));
+        assertThat(serverSpan.getAttributes(), hasAttribute(UrlAttributes.URL_SCHEME, "http"));
+        String userAgent = serverSpan.getAttributes().get(UserAgentAttributes.USER_AGENT_ORIGINAL);
+        assertNotNull(userAgent);
+        assertThat(userAgent, containsString("Apache-CXF/"));
     }
 
     @Test
@@ -161,11 +187,33 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
         assertThat(otelRule.getSpans().size(), equalTo(3));
         assertThat(otelRule.getSpans().get(0).getName(), equalTo("Get Books"));
         assertThat(otelRule.getSpans().get(0).getParentSpanContext().isValid(), equalTo(true));
-        assertThat(otelRule.getSpans().get(1).getName(), equalTo("POST /BookStore"));
-        assertThat(otelRule.getSpans().get(1).getKind(), equalTo(SpanKind.SERVER));
-        assertThat(otelRule.getSpans().get(2).getName(),
-                   equalTo("POST http://localhost:" + PORT + "/BookStore"));
-        assertThat(otelRule.getSpans().get(2).getKind(), equalTo(SpanKind.CLIENT));
+
+        SpanData serverSpan = otelRule.getSpans().get(1);
+        assertThat(serverSpan.getName(), equalTo("POST /BookStore"));
+        assertThat(serverSpan.getKind(), equalTo(SpanKind.SERVER));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD, "POST"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(UrlAttributes.URL_PATH, "/BookStore"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_ADDRESS, "localhost"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(PORT)));
+        assertThat(serverSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"));
+        assertNotNull(serverSpan.getAttributes().get(NetworkAttributes.NETWORK_PEER_PORT));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ClientAttributes.CLIENT_ADDRESS, "127.0.0.1"));
+        assertNotNull(serverSpan.getAttributes().get(ClientAttributes.CLIENT_PORT));
+
+        assertThat(serverSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"));
+
+        SpanData clientSpan = otelRule.getSpans().get(2);
+        assertThat(clientSpan.getName(), equalTo("POST http://localhost:" + PORT + "/BookStore"));
+        assertThat(clientSpan.getKind(), equalTo(SpanKind.CLIENT));
+        assertThat(clientSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
+        assertThat(clientSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD, "POST"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(UrlAttributes.URL_FULL,
+                "http://localhost:" + PORT + "/BookStore"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_ADDRESS, "localhost"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(PORT)));
+        assertThat(clientSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, "localhost"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_PORT,  Long.valueOf(PORT)));
     }
 
     @Test
@@ -190,7 +238,7 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
                 assertThat(otelRule.getSpans().get(1).getInstrumentationScopeInfo().getName(),
                            equalTo("jaxws-server-test"));
                 assertThat(otelRule.getSpans().get(2).getName(),
-                           equalTo("POST http://localhost:" + PORT + "/BookStore"));
+                        equalTo("POST http://localhost:" + PORT + "/BookStore"));
                 assertThat(otelRule.getSpans().get(2).getParentSpanContext().isValid(), equalTo(true));
                 assertThat(otelRule.getSpans().get(2).getInstrumentationScopeInfo().getName(),
                            equalTo("jaxws-client-test"));
@@ -235,11 +283,32 @@ public class OpenTelemetryTracingTest extends AbstractClientServerTestBase {
         }
 
         assertThat(otelRule.getSpans().size(), equalTo(2));
-        assertThat(otelRule.getSpans().get(0).getName(), equalTo("POST /BookStore"));
-        assertThat(otelRule.getSpans().get(0).getAttributes(),
-                   hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500L));
-        assertThat(otelRule.getSpans().get(1).getName(),
-                   equalTo("POST http://localhost:" + PORT + "/BookStore"));
+
+        SpanData serverSpan = otelRule.getSpans().get(0);
+        assertThat(serverSpan.getName(), equalTo("POST /BookStore"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500L));
+        assertThat(serverSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD, "POST"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(UrlAttributes.URL_PATH, "/BookStore"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(UrlAttributes.URL_SCHEME, "http"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_ADDRESS, "localhost"));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(PORT)));
+        assertThat(serverSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"));
+        assertNotNull(serverSpan.getAttributes().get(NetworkAttributes.NETWORK_PEER_PORT));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ClientAttributes.CLIENT_ADDRESS, "127.0.0.1"));
+        assertNotNull(serverSpan.getAttributes().get(ClientAttributes.CLIENT_PORT));
+        assertThat(serverSpan.getAttributes(), hasAttribute(ErrorAttributes.ERROR_TYPE,  String.valueOf(500)));
+
+        SpanData clientSpan = otelRule.getSpans().get(1);
+        assertThat(clientSpan.getName(), equalTo("POST http://localhost:" + PORT + "/BookStore"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500L));
+        assertThat(clientSpan.getAttributes(), hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD, "POST"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(UrlAttributes.URL_FULL,
+                "http://localhost:" + PORT + "/BookStore"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_ADDRESS, "localhost"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(ServerAttributes.SERVER_PORT, Long.valueOf(PORT)));
+        assertThat(clientSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_ADDRESS, "localhost"));
+        assertThat(clientSpan.getAttributes(), hasAttribute(NetworkAttributes.NETWORK_PEER_PORT,  Long.valueOf(PORT)));
+        assertThat(clientSpan.getAttributes(), hasAttribute(ErrorAttributes.ERROR_TYPE,  String.valueOf(500)));
     }
 
     @Test


(cxf) 03/04: CXF-9055: Follow OpenTelemetry semconv for trace span and its attributes (minor code cleanups)

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 5215981078050a997e7a48749c3383a42528864c
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Fri Sep 13 17:37:13 2024 -0400

    CXF-9055: Follow OpenTelemetry semconv for trace span and its attributes (minor code cleanups)
    
    (cherry picked from commit 4cb2fc8d52c01f402d632d447cf5fdf26b2f371e)
---
 .../cxf/tracing/opentelemetry/OpenTelemetryStartInterceptor.java    | 5 +++--
 .../cxf/tracing/opentelemetry/jaxrs/OpenTelemetryProvider.java      | 6 +++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/OpenTelemetryStartInterceptor.java b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/OpenTelemetryStartInterceptor.java
index d7aa118cc4..8a45b644ab 100644
--- a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/OpenTelemetryStartInterceptor.java
+++ b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/OpenTelemetryStartInterceptor.java
@@ -71,8 +71,9 @@ public class OpenTelemetryStartInterceptor extends AbstractOpenTelemetryIntercep
                 span.setAttribute(NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
             }
 
-            if (request.getHeader("User-Agent") != null) {
-                span.setAttribute(UserAgentAttributes.USER_AGENT_ORIGINAL, request.getHeader("User-Agent"));
+            final String userAgent = request.getHeader("User-Agent");
+            if (userAgent != null) {
+                span.setAttribute(UserAgentAttributes.USER_AGENT_ORIGINAL, userAgent);
             }
         }
     }
diff --git a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/jaxrs/OpenTelemetryProvider.java b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/jaxrs/OpenTelemetryProvider.java
index 4b8759fdf9..a3d02509fa 100644
--- a/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/jaxrs/OpenTelemetryProvider.java
+++ b/integration/tracing/tracing-opentelemetry/src/main/java/org/apache/cxf/tracing/opentelemetry/jaxrs/OpenTelemetryProvider.java
@@ -76,7 +76,11 @@ public class OpenTelemetryProvider extends AbstractOpenTelemetryProvider
                 String protocolVersion = protocol.split("/")[1];
                 span.setAttribute(NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
             }
-            span.setAttribute(UserAgentAttributes.USER_AGENT_ORIGINAL, request.getHeader("User-Agent"));
+            
+            final String userAgent = request.getHeader("User-Agent");
+            if (userAgent != null) {
+                span.setAttribute(UserAgentAttributes.USER_AGENT_ORIGINAL, userAgent);
+            }
         }
 
         if (holder != null) {


(cxf) 04/04: Recording .gitmergeinfo Changes

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit ab0a279f62d25d16fdd54ed44158926ea0bfdd34
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Fri Sep 13 17:38:52 2024 -0400

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 78f262db79..1ee9dfce83 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -24,6 +24,7 @@ M 1dfc5df495acdab16ef48597719963d4c4adf75e
 M 1e008f16c857d712f7167823fbf5a94b87779d3a
 M 1e0cc57602b04ea9fba002cb6d4b4293a27941a1
 M 1e126703214ec99a3c20f6906e5fc29eee9594c3
+M 228aee8f5622dc3aa93b3d89d3165cc9b05f6c6e
 M 22b4825062439d0494b399d1ed89ba978450c81b
 M 22bd868f6b57b1121e2542e2d8e60f86c26c54b0
 M 234eab1d3505bd892f0517a2f6b9bc512475facf
@@ -37,6 +38,7 @@ M 3165e676100f619ef77c540fbc3964feb6d5cbb4
 M 3194e058bde505738093191819de399e5bcb013c
 M 32b2732b6884de3c60322f20657419db1d838e8a
 M 3414297730d61914ec574eeae51f0c49a630d74b
+M 367d1204d0d8199efbe32ad3096d0fc09cdeae34
 M 369465b3243f0f01ec86a6911a9c216d46de8fb4
 M 388cf563fef2ff90d5701113ac38cebdd2bd185d
 M 3896935619e1bbdc3ba8dce54755be646f53cab4
@@ -123,6 +125,7 @@ M acc610299dc7e3d32e658649766d26452d15dea8
 M ace3b1901cb64a6f98e51dc9bbffe7cbeb4f4c1c
 M af7038490d5685a456d9f7e9e424a228416d1bf5
 M af85f026d6c57aa79263e46657aba7e5d2d590ea
+M b14fbbbf352043171e1ecf958d5865d4c5439af2
 M b358f81708dbec95437f04be280fa0782b387f70
 M b660f71147311745fb7aee2e8834f30d12e98037
 M b8cf8adf5842b98e6a2cac53a40a7aba414e13a0


(cxf) 01/04: Bump org.jboss.logging:jboss-logging from 3.6.0.Final to 3.6.1.Final (#2064)

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 821679342c113aaed3662371cdf08a74596176c3
Author: dependabot[bot] <49...@users.noreply.github.com>
AuthorDate: Thu Sep 12 07:23:35 2024 -0400

    Bump org.jboss.logging:jboss-logging from 3.6.0.Final to 3.6.1.Final (#2064)
    
    Bumps [org.jboss.logging:jboss-logging](https://github.com/jboss-logging/jboss-logging) from 3.6.0.Final to 3.6.1.Final.
    - [Release notes](https://github.com/jboss-logging/jboss-logging/releases)
    - [Commits](https://github.com/jboss-logging/jboss-logging/compare/3.6.0.Final...3.6.1.Final)
    
    ---
    updated-dependencies:
    - dependency-name: org.jboss.logging:jboss-logging
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <su...@github.com>
    Co-authored-by: dependabot[bot] <49...@users.noreply.github.com>
    (cherry picked from commit 367d1204d0d8199efbe32ad3096d0fc09cdeae34)
    
    # Conflicts:
    #       parent/pom.xml
---
 parent/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index ee59bdad53..5af8d89276 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -155,7 +155,7 @@
         <cxf.jaxb.version>3.0.1</cxf.jaxb.version>
         <cxf.jaxb.xjc.version>${cxf.jaxb.runtime.version}</cxf.jaxb.xjc.version>
         <cxf.jaxen.version>2.0.0</cxf.jaxen.version>
-        <cxf.jboss.logging.version>3.6.0.Final</cxf.jboss.logging.version>
+        <cxf.jboss.logging.version>3.6.1.Final</cxf.jboss.logging.version>
         <cxf.jboss.weld.version>4.0.3.Final</cxf.jboss.weld.version>
         <cxf.jboss.narayana.version>5.13.1.Final</cxf.jboss.narayana.version>
         <cxf.jcache.version>1.1.1</cxf.jcache.version>