File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed 
spring-boot-project/spring-boot-actuator/src 
main/java/org/springframework/boot/actuate/metrics/web/reactive/server 
test/java/org/springframework/boot/actuate/metrics/web/reactive/server Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 2020
2121import  org .springframework .boot .actuate .metrics .http .Outcome ;
2222import  org .springframework .http .HttpStatus ;
23+ import  org .springframework .http .server .reactive .AbstractServerHttpResponse ;
24+ import  org .springframework .http .server .reactive .ServerHttpResponse ;
2325import  org .springframework .util .StringUtils ;
2426import  org .springframework .web .reactive .HandlerMapping ;
2527import  org .springframework .web .server .ServerWebExchange ;
@@ -133,9 +135,18 @@ public static Tag exception(Throwable exception) {
133135	 * @since 2.1.0 
134136	 */ 
135137	public  static  Tag  outcome (ServerWebExchange  exchange ) {
136- 		HttpStatus   status  = exchange . getResponse (). getStatusCode ( );
137- 		Outcome  outcome  = (status  != null ) ? Outcome .forStatus (status . value () ) : Outcome .UNKNOWN ;
138+ 		Integer   statusCode  = extractStatusCode ( exchange );
139+ 		Outcome  outcome  = (statusCode  != null ) ? Outcome .forStatus (statusCode ) : Outcome .UNKNOWN ;
138140		return  outcome .asTag ();
139141	}
140142
143+ 	private  static  Integer  extractStatusCode (ServerWebExchange  exchange ) {
144+ 		ServerHttpResponse  response  = exchange .getResponse ();
145+ 		if  (response  instanceof  AbstractServerHttpResponse ) {
146+ 			return  ((AbstractServerHttpResponse ) response ).getStatusCodeValue ();
147+ 		}
148+ 		HttpStatus  status  = response .getStatusCode ();
149+ 		return  (status  != null ) ? status .value () : null ;
150+ 	}
151+ 
141152}
Original file line number Diff line number Diff line change @@ -152,4 +152,18 @@ void outcomeTagIsServerErrorWhenResponseIs5xx() {
152152		assertThat (tag .getValue ()).isEqualTo ("SERVER_ERROR" );
153153	}
154154
155+ 	@ Test 
156+ 	void  outcomeTagIsClientErrorWhenResponseIsNonStandardInClientSeries () {
157+ 		this .exchange .getResponse ().setStatusCodeValue (490 );
158+ 		Tag  tag  = WebFluxTags .outcome (this .exchange );
159+ 		assertThat (tag .getValue ()).isEqualTo ("CLIENT_ERROR" );
160+ 	}
161+ 
162+ 	@ Test 
163+ 	void  outcomeTagIsUnknownWhenResponseStatusIsInUnknownSeries () {
164+ 		this .exchange .getResponse ().setStatusCodeValue (701 );
165+ 		Tag  tag  = WebFluxTags .outcome (this .exchange );
166+ 		assertThat (tag .getValue ()).isEqualTo ("UNKNOWN" );
167+ 	}
168+ 
155169}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments