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 2021/09/03 15:01:12 UTC

[cxf] branch 3.3.x-fixes updated: CXF-8588: Micrometer operation UNKNOWN for clients (#844)

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

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


The following commit(s) were added to refs/heads/3.3.x-fixes by this push:
     new b532c50  CXF-8588: Micrometer operation UNKNOWN for clients (#844)
b532c50 is described below

commit b532c50de878a6676d9ae9479799e42b3d4abe99
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Fri Sep 3 07:34:22 2021 -0400

    CXF-8588: Micrometer operation UNKNOWN for clients (#844)
    
    (cherry picked from commit 6b8aa02b357f66a1ec9fbc0ae7410ab975824618)
    (cherry picked from commit 71ce08db632a3d7df8d8bd62e6f5742bab6bac77)
---
 .../apache/cxf/metrics/micrometer/provider/jaxrs/JaxrsTags.java  | 9 +++++++++
 .../systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java    | 8 ++++----
 .../apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java    | 8 ++++----
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/micrometer/provider/jaxrs/JaxrsTags.java b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/micrometer/provider/jaxrs/JaxrsTags.java
index d966445..8f22d45 100644
--- a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/micrometer/provider/jaxrs/JaxrsTags.java
+++ b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/micrometer/provider/jaxrs/JaxrsTags.java
@@ -39,6 +39,15 @@ public class JaxrsTags {
             .flatMap(MessageUtils::getTargetMethod)
             .map(Method::getName)
             .map(operation -> Tag.of("operation", operation))
+            .orElseGet(() -> method(request));
+    }
+    
+    public Tag method(Message request) {
+        return ofNullable(request)
+            .map(Message::getExchange)
+            .map(ex -> ex.get(Method.class))
+            .map(Method::getName)
+            .map(operation -> Tag.of("operation", operation))
             .orElse(OPERATION_UNKNOWN);
     }
 }
diff --git a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java
index f66c86a..9c41626 100644
--- a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java
+++ b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java
@@ -345,7 +345,7 @@ public class SpringJaxrsApplicationTest {
             .containsOnly(
                 entry("exception", "None"),
                 entry("method", "GET"),
-                entry("operation", "UNKNOWN"),
+                entry("operation", "getBooks"),
                 entry("uri", "http://localhost:" + port + "/api/app/library"),
                 entry("outcome", "SUCCESS"),
                 entry("status", "200"));
@@ -386,7 +386,7 @@ public class SpringJaxrsApplicationTest {
             .containsOnly(
                 entry("exception", "None"),
                 entry("method", "DELETE"),
-                entry("operation", "UNKNOWN"),
+                entry("operation", "deleteBooks"),
                 entry("uri", "http://localhost:" + port + "/api/app/library"),
                 entry("outcome", "SERVER_ERROR"),
                 entry("status", "500"));
@@ -427,7 +427,7 @@ public class SpringJaxrsApplicationTest {
             .containsOnly(
                 entry("exception", "None"),
                 entry("method", "GET"),
-                entry("operation", "UNKNOWN"),
+                entry("operation", "getBook"),
                 entry("uri", "http://localhost:" + port + "/api/app/library/100"),
                 entry("outcome", "CLIENT_ERROR"),
                 entry("status", "404"));
@@ -455,7 +455,7 @@ public class SpringJaxrsApplicationTest {
             .containsOnly(
                 entry("exception", "None"),
                 entry("method", "DELETE"),
-                entry("operation", "UNKNOWN"),
+                entry("operation", "deleteBooks"),
                 entry("uri", "http://localhost:" + fakePort + "/api/app/library"),
                 entry("outcome", "UNKNOWN"),
                 entry("status", "UNKNOWN"));
diff --git a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java
index 5607a99..3f77f8f 100644
--- a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java
+++ b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java
@@ -305,7 +305,7 @@ public class SpringJaxrsTest {
             .containsOnly(
                 entry("exception", "None"),
                 entry("method", "GET"),
-                entry("operation", "UNKNOWN"),
+                entry("operation", "getBooks"),
                 entry("uri", "http://localhost:" + port + "/api/library"),
                 entry("outcome", "SUCCESS"),
                 entry("status", "200"));
@@ -346,7 +346,7 @@ public class SpringJaxrsTest {
             .containsOnly(
                 entry("exception", "None"),
                 entry("method", "DELETE"),
-                entry("operation", "UNKNOWN"),
+                entry("operation", "deleteBooks"),
                 entry("uri", "http://localhost:" + port + "/api/library"),
                 entry("outcome", "SERVER_ERROR"),
                 entry("status", "500"));
@@ -387,7 +387,7 @@ public class SpringJaxrsTest {
             .containsOnly(
                 entry("exception", "None"),
                 entry("method", "GET"),
-                entry("operation", "UNKNOWN"),
+                entry("operation", "getBook"),
                 entry("uri", "http://localhost:" + port + "/api/library/100"),
                 entry("outcome", "CLIENT_ERROR"),
                 entry("status", "404"));
@@ -415,7 +415,7 @@ public class SpringJaxrsTest {
             .containsOnly(
                 entry("exception", "None"),
                 entry("method", "DELETE"),
-                entry("operation", "UNKNOWN"),
+                entry("operation", "deleteBooks"),
                 entry("uri", "http://localhost:" + fakePort + "/api/library"),
                 entry("outcome", "UNKNOWN"),
                 entry("status", "UNKNOWN"));