1717package org .springframework .ws .transport .observation ;
1818
1919import java .net .URI ;
20- import java .net . URISyntaxException ;
20+ import java .util . Objects ;
2121
2222import javax .xml .namespace .QName ;
2323
2424import io .micrometer .common .KeyValue ;
2525import io .micrometer .common .KeyValues ;
26- import org .jspecify .annotations .Nullable ;
2726
2827import org .springframework .ws .FaultAwareWebServiceMessage ;
2928import org .springframework .ws .WebServiceMessage ;
3029import org .springframework .ws .transport .observation .SoapServerObservationDocumentation .HighCardinalityKeyNames ;
3130import org .springframework .ws .transport .observation .SoapServerObservationDocumentation .LowCardinalityKeyNames ;
3231
3332/**
34- * Default {@link SoapServerObservationConvention}.
33+ * Default {@link SoapServerObservationConvention} implementation .
3534 *
3635 * @author Brian Clozel
3736 * @since 5.1.0
3837 */
39- public class DefaultSoapServerObservationConvention extends SoapServerObservationConvention {
38+ public class DefaultSoapServerObservationConvention implements SoapServerObservationConvention {
4039
41- private static final String DEFAULT_NAME = "soap.server.duration " ;
40+ private static final String DEFAULT_NAME = "soap.server.requests " ;
4241
4342 private final String name ;
4443
@@ -64,15 +63,15 @@ public String getName() {
6463
6564 @ Override
6665 public String getContextualName (SoapServerObservationContext context ) {
67- if (context .getMethodName () != null ) {
68- return "soap " + context .getMethodName ();
66+ if (context .getOperationName () != null ) {
67+ return "soap " + context .getOperationName ();
6968 }
7069 return "soap" ;
7170 }
7271
7372 @ Override
7473 public KeyValues getLowCardinalityKeyValues (SoapServerObservationContext context ) {
75- return KeyValues .of (faultCode (context ), method (context ), address (context ), protocol ( context ), service (context ));
74+ return KeyValues .of (faultCode (context ), namespace (context ), operationName (context ), protocol (context ));
7675 }
7776
7877 private KeyValue faultCode (SoapServerObservationContext context ) {
@@ -86,59 +85,29 @@ private KeyValue faultCode(SoapServerObservationContext context) {
8685 return KeyValue .of (LowCardinalityKeyNames .FAULT_CODE , KeyValue .NONE_VALUE );
8786 }
8887
89- private KeyValue method (SoapServerObservationContext context ) {
90- if (context .getMethodName () != null ) {
91- return KeyValue .of (LowCardinalityKeyNames .METHOD , context .getMethodName ());
92- }
93- return KeyValue .of (LowCardinalityKeyNames .METHOD , KeyValue .NONE_VALUE );
88+ private KeyValue namespace (SoapServerObservationContext context ) {
89+ return KeyValue .of (LowCardinalityKeyNames .NAMESPACE ,
90+ Objects .requireNonNullElse (context .getNamespace (), KeyValue .NONE_VALUE ));
9491 }
9592
96- private KeyValue address (SoapServerObservationContext context ) {
97- URI uri = getConnectionURI (context );
98- if (uri != null ) {
99- return KeyValue .of (LowCardinalityKeyNames .ADDRESS , uri .getHost ());
93+ private KeyValue operationName (SoapServerObservationContext context ) {
94+ if (context .getOperationName () != null ) {
95+ return KeyValue .of (LowCardinalityKeyNames .OPERATION_NAME , context .getOperationName ());
10096 }
101- return KeyValue .of (LowCardinalityKeyNames .ADDRESS , KeyValue .NONE_VALUE );
97+ return KeyValue .of (LowCardinalityKeyNames .OPERATION_NAME , KeyValue .NONE_VALUE );
10298 }
10399
104100 private KeyValue protocol (SoapServerObservationContext context ) {
105- URI uri = getConnectionURI (context );
106- if (uri != null ) {
107- return KeyValue .of (LowCardinalityKeyNames .PROTOCOL , uri .getScheme ());
108- }
109- return KeyValue .of (LowCardinalityKeyNames .PROTOCOL , KeyValue .NONE_VALUE );
110- }
111-
112- private KeyValue service (SoapServerObservationContext context ) {
113- String serviceName = context .getServiceName ();
114- if (serviceName != null ) {
115- return KeyValue .of (LowCardinalityKeyNames .SERVICE , serviceName );
116- }
117- return KeyValue .of (LowCardinalityKeyNames .SERVICE , KeyValue .NONE_VALUE );
118- }
119-
120- private @ Nullable URI getConnectionURI (SoapServerObservationContext context ) {
121- try {
122- return context .getConnection ().getUri ();
123- }
124- catch (URISyntaxException exc ) {
125- return null ;
126- }
101+ URI uri = context .getUri ();
102+ String protocol = (uri != null ) ? uri .getScheme () : KeyValue .NONE_VALUE ;
103+ return KeyValue .of (LowCardinalityKeyNames .PROTOCOL , protocol );
127104 }
128105
129106 @ Override
130107 public KeyValues getHighCardinalityKeyValues (SoapServerObservationContext context ) {
131108 return KeyValues .of (faultReason (context ), uri (context ));
132109 }
133110
134- private KeyValue uri (SoapServerObservationContext context ) {
135- URI uri = getConnectionURI (context );
136- if (uri != null ) {
137- return KeyValue .of (HighCardinalityKeyNames .URL , uri .toString ());
138- }
139- return KeyValue .of (HighCardinalityKeyNames .URL , KeyValue .NONE_VALUE );
140- }
141-
142111 private KeyValue faultReason (SoapServerObservationContext context ) {
143112 WebServiceMessage response = context .getResponse ();
144113 if (response instanceof FaultAwareWebServiceMessage faultResponse ) {
@@ -150,4 +119,10 @@ private KeyValue faultReason(SoapServerObservationContext context) {
150119 return KeyValue .of (HighCardinalityKeyNames .FAULT_REASON , KeyValue .NONE_VALUE );
151120 }
152121
122+ private KeyValue uri (SoapServerObservationContext context ) {
123+ URI uri = context .getUri ();
124+ String value = (uri != null ) ? uri .toString () : KeyValue .NONE_VALUE ;
125+ return KeyValue .of (HighCardinalityKeyNames .URI , value );
126+ }
127+
153128}
0 commit comments