Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
b15e427a
Commit
b15e427a
authored
Sep 18, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve handling of non-standard status codes in WebFluxTags
Closes gh-18267
parent
6534047f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
WebFluxTags.java
...boot/actuate/metrics/web/reactive/server/WebFluxTags.java
+13
-2
WebFluxTagsTests.java
...actuate/metrics/web/reactive/server/WebFluxTagsTests.java
+14
-0
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java
View file @
b15e427a
...
@@ -20,6 +20,8 @@ import io.micrometer.core.instrument.Tag;
...
@@ -20,6 +20,8 @@ import io.micrometer.core.instrument.Tag;
import
org.springframework.boot.actuate.metrics.http.Outcome
;
import
org.springframework.boot.actuate.metrics.http.Outcome
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.server.reactive.AbstractServerHttpResponse
;
import
org.springframework.http.server.reactive.ServerHttpResponse
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.reactive.HandlerMapping
;
import
org.springframework.web.reactive.HandlerMapping
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.ServerWebExchange
;
...
@@ -133,9 +135,18 @@ public final class WebFluxTags {
...
@@ -133,9 +135,18 @@ public final class WebFluxTags {
* @since 2.1.0
* @since 2.1.0
*/
*/
public
static
Tag
outcome
(
ServerWebExchange
exchange
)
{
public
static
Tag
outcome
(
ServerWebExchange
exchange
)
{
HttpStatus
status
=
exchange
.
getResponse
().
getStatusCode
(
);
Integer
statusCode
=
extractStatusCode
(
exchange
);
Outcome
outcome
=
(
status
!=
null
)
?
Outcome
.
forStatus
(
status
.
value
()
)
:
Outcome
.
UNKNOWN
;
Outcome
outcome
=
(
status
Code
!=
null
)
?
Outcome
.
forStatus
(
statusCode
)
:
Outcome
.
UNKNOWN
;
return
outcome
.
asTag
();
return
outcome
.
asTag
();
}
}
private
static
Integer
extractStatusCode
(
ServerWebExchange
exchange
)
{
ServerHttpResponse
response
=
exchange
.
getResponse
();
if
(
response
instanceof
AbstractServerHttpResponse
)
{
return
((
AbstractServerHttpResponse
)
response
).
getStatusCodeValue
();
}
HttpStatus
status
=
response
.
getStatusCode
();
return
(
status
!=
null
)
?
status
.
value
()
:
null
;
}
}
}
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java
View file @
b15e427a
...
@@ -152,4 +152,18 @@ class WebFluxTagsTests {
...
@@ -152,4 +152,18 @@ class WebFluxTagsTests {
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"SERVER_ERROR"
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"SERVER_ERROR"
);
}
}
@Test
void
outcomeTagIsClientErrorWhenResponseIsNonStandardInClientSeries
()
{
this
.
exchange
.
getResponse
().
setStatusCodeValue
(
490
);
Tag
tag
=
WebFluxTags
.
outcome
(
this
.
exchange
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"CLIENT_ERROR"
);
}
@Test
void
outcomeTagIsUnknownWhenResponseStatusIsInUnknownSeries
()
{
this
.
exchange
.
getResponse
().
setStatusCodeValue
(
701
);
Tag
tag
=
WebFluxTags
.
outcome
(
this
.
exchange
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"UNKNOWN"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment