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
608228d6
Commit
608228d6
authored
Aug 23, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve handling of non-standard status codes in WebClient metrics
Fixes gh-17695
parent
52050c17
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
5 deletions
+11
-5
WebClientExchangeTags.java
...te/metrics/web/reactive/client/WebClientExchangeTags.java
+1
-1
DefaultWebClientExchangeTagsProviderTests.java
...ive/client/DefaultWebClientExchangeTagsProviderTests.java
+1
-1
MetricsWebClientFilterFunctionTests.java
.../reactive/client/MetricsWebClientFilterFunctionTests.java
+2
-2
WebClientExchangeTagsTests.java
...trics/web/reactive/client/WebClientExchangeTagsTests.java
+7
-1
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java
View file @
608228d6
...
...
@@ -80,7 +80,7 @@ public final class WebClientExchangeTags {
* @return the status tag
*/
public
static
Tag
status
(
ClientResponse
response
)
{
return
Tag
.
of
(
"status"
,
String
.
valueOf
(
response
.
statusCode
().
valu
e
()));
return
Tag
.
of
(
"status"
,
String
.
valueOf
(
response
.
rawStatusCod
e
()));
}
/**
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java
View file @
608228d6
...
...
@@ -53,7 +53,7 @@ public class DefaultWebClientExchangeTagsProviderTests {
this
.
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
URI
.
create
(
"https://example.org/projects/spring-boot"
))
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"https://example.org/projects/{project}"
).
build
();
this
.
response
=
mock
(
ClientResponse
.
class
);
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
given
(
this
.
response
.
rawStatusCode
()).
willReturn
(
HttpStatus
.
OK
.
value
()
);
}
@Test
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunctionTests.java
View file @
608228d6
...
...
@@ -71,7 +71,7 @@ public class MetricsWebClientFilterFunctionTests {
public
void
filterShouldRecordTimer
()
{
ClientRequest
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
URI
.
create
(
"https://example.com/projects/spring-boot"
)).
build
();
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
given
(
this
.
response
.
rawStatusCode
()).
willReturn
(
HttpStatus
.
OK
.
value
()
);
this
.
filterFunction
.
filter
(
request
,
this
.
exchange
).
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
this
.
registry
.
get
(
"http.client.requests"
)
.
tags
(
"method"
,
"GET"
,
"uri"
,
"/projects/spring-boot"
,
"status"
,
"200"
).
timer
().
count
()).
isEqualTo
(
1
);
...
...
@@ -82,7 +82,7 @@ public class MetricsWebClientFilterFunctionTests {
ClientRequest
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
URI
.
create
(
"https://example.com/projects/spring-boot"
))
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"/projects/{project}"
).
build
();
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
given
(
this
.
response
.
rawStatusCode
()).
willReturn
(
HttpStatus
.
OK
.
value
()
);
this
.
filterFunction
.
filter
(
request
,
this
.
exchange
).
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
this
.
registry
.
get
(
"http.client.requests"
)
.
tags
(
"method"
,
"GET"
,
"uri"
,
"/projects/{project}"
,
"status"
,
"200"
).
timer
().
count
()).
isEqualTo
(
1
);
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java
View file @
608228d6
...
...
@@ -51,7 +51,6 @@ public class WebClientExchangeTagsTests {
this
.
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
URI
.
create
(
"https://example.org/projects/spring-boot"
))
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"https://example.org/projects/{project}"
).
build
();
this
.
response
=
mock
(
ClientResponse
.
class
);
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
}
@Test
...
...
@@ -85,6 +84,7 @@ public class WebClientExchangeTagsTests {
@Test
public
void
status
()
{
given
(
this
.
response
.
rawStatusCode
()).
willReturn
(
HttpStatus
.
OK
.
value
());
assertThat
(
WebClientExchangeTags
.
status
(
this
.
response
)).
isEqualTo
(
Tag
.
of
(
"status"
,
"200"
));
}
...
...
@@ -99,4 +99,10 @@ public class WebClientExchangeTagsTests {
.
isEqualTo
(
Tag
.
of
(
"status"
,
"CLIENT_ERROR"
));
}
@Test
public
void
statusWhenNonStandard
()
{
given
(
this
.
response
.
rawStatusCode
()).
willReturn
(
490
);
assertThat
(
WebClientExchangeTags
.
status
(
this
.
response
)).
isEqualTo
(
Tag
.
of
(
"status"
,
"490"
));
}
}
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