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
9f6c5e4e
Commit
9f6c5e4e
authored
Jan 28, 2019
by
Johnny Lim
Committed by
Andy Wilkinson
Feb 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
b5c9afc0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
33 deletions
+25
-33
RestTemplateExchangeTags.java
.../actuate/metrics/web/client/RestTemplateExchangeTags.java
+20
-27
WebClientExchangeTags.java
...te/metrics/web/reactive/client/WebClientExchangeTags.java
+1
-1
RestTemplateExchangeTagsTests.java
...ate/metrics/web/client/RestTemplateExchangeTagsTests.java
+1
-2
WebClientExchangeTagsTests.java
...trics/web/reactive/client/WebClientExchangeTagsTests.java
+3
-3
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java
View file @
9f6c5e4e
...
...
@@ -131,43 +131,36 @@ public final class RestTemplateExchangeTags {
}
/**
* Creates a {@code outcome} {@code Tag} derived from the
* Creates a
n
{@code outcome} {@code Tag} derived from the
* {@link ClientHttpResponse#getStatusCode() status} of the given {@code response}.
* @param response the response
* @return the outcome tag
* @since 2.2.0
*/
public
static
Tag
outcome
(
ClientHttpResponse
response
)
{
HttpStatus
status
=
extractStatus
(
response
);
if
(
status
!=
null
)
{
if
(
status
.
is1xxInformational
())
{
return
OUTCOME_INFORMATIONAL
;
}
if
(
status
.
is2xxSuccessful
())
{
return
OUTCOME_SUCCESS
;
}
if
(
status
.
is3xxRedirection
())
{
return
OUTCOME_REDIRECTION
;
}
if
(
status
.
is4xxClientError
())
{
return
OUTCOME_CLIENT_ERROR
;
}
if
(
status
.
is5xxServerError
())
{
return
OUTCOME_SERVER_ERROR
;
}
}
return
OUTCOME_UNKNOWN
;
}
private
static
HttpStatus
extractStatus
(
ClientHttpResponse
response
)
{
try
{
if
(
response
!=
null
)
{
return
response
.
getStatusCode
();
HttpStatus
statusCode
=
response
.
getStatusCode
();
if
(
statusCode
.
is1xxInformational
())
{
return
OUTCOME_INFORMATIONAL
;
}
if
(
statusCode
.
is2xxSuccessful
())
{
return
OUTCOME_SUCCESS
;
}
if
(
statusCode
.
is3xxRedirection
())
{
return
OUTCOME_REDIRECTION
;
}
if
(
statusCode
.
is4xxClientError
())
{
return
OUTCOME_CLIENT_ERROR
;
}
if
(
statusCode
.
is5xxServerError
())
{
return
OUTCOME_SERVER_ERROR
;
}
}
return
null
;
return
OUTCOME_UNKNOWN
;
}
catch
(
IOException
|
IllegalArgumentException
ex
c
)
{
return
null
;
catch
(
IOException
|
IllegalArgumentException
ex
)
{
return
OUTCOME_UNKNOWN
;
}
}
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java
View file @
9f6c5e4e
...
...
@@ -126,7 +126,7 @@ public final class WebClientExchangeTags {
}
/**
* Creates a {@code outcome} {@code Tag} derived from the
* Creates a
n
{@code outcome} {@code Tag} derived from the
* {@link ClientResponse#statusCode() status} of the given {@code response}.
* @param response the response
* @return the outcome tag
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTagsTests.java
View file @
9f6c5e4e
...
...
@@ -34,12 +34,11 @@ import static org.mockito.Mockito.mock;
*
* @author Nishant Raut
* @author Brian Clozel
* @author Brian Clozel
*/
public
class
RestTemplateExchangeTagsTests
{
@Test
public
void
outcomeTagIsUnknownWhenResponse
Status
IsNull
()
{
public
void
outcomeTagIsUnknownWhenResponseIsNull
()
{
Tag
tag
=
RestTemplateExchangeTags
.
outcome
(
null
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"UNKNOWN"
);
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java
View file @
9f6c5e4e
...
...
@@ -34,7 +34,7 @@ import static org.mockito.BDDMockito.given;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
* Tests for {@link WebClientExchangeTags}
* Tests for {@link WebClientExchangeTags}
.
*
* @author Brian Clozel
* @author Nishant Raut
...
...
@@ -115,7 +115,7 @@ public class WebClientExchangeTagsTests {
}
@Test
public
void
outcomeTagIsUnknownWhenResponse
Status
IsNull
()
{
public
void
outcomeTagIsUnknownWhenResponseIsNull
()
{
Tag
tag
=
WebClientExchangeTags
.
outcome
(
null
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"UNKNOWN"
);
}
...
...
@@ -156,7 +156,7 @@ public class WebClientExchangeTagsTests {
}
@Test
public
void
outcomeTagIsU
knownWhenResponseStatusIsU
known
()
{
public
void
outcomeTagIsU
nknownWhenResponseStatusIsUn
known
()
{
given
(
this
.
response
.
statusCode
()).
willThrow
(
IllegalArgumentException
.
class
);
Tag
tag
=
WebClientExchangeTags
.
outcome
(
this
.
response
);
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