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
592754d8
Commit
592754d8
authored
Jul 19, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Make sure exception tag values are not empty in web metrics"
Closes gh-13187
parent
ee37dc1c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
16 deletions
+19
-16
WebFluxTags.java
...boot/actuate/metrics/web/reactive/server/WebFluxTags.java
+3
-1
WebMvcTags.java
...ramework/boot/actuate/metrics/web/servlet/WebMvcTags.java
+2
-1
MetricsWebFilterTests.java
...te/metrics/web/reactive/server/MetricsWebFilterTests.java
+3
-5
WebMvcMetricsFilterTests.java
...actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java
+11
-9
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java
View file @
592754d8
...
...
@@ -19,6 +19,7 @@ package org.springframework.boot.actuate.metrics.web.reactive.server;
import
io.micrometer.core.instrument.Tag
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.reactive.HandlerMapping
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.util.pattern.PathPattern
;
...
...
@@ -110,7 +111,8 @@ public final class WebFluxTags {
public
static
Tag
exception
(
Throwable
exception
)
{
if
(
exception
!=
null
)
{
String
simpleName
=
exception
.
getClass
().
getSimpleName
();
return
Tag
.
of
(
"exception"
,
simpleName
.
isEmpty
()
?
exception
.
getClass
().
getName
()
:
simpleName
);
return
Tag
.
of
(
"exception"
,
StringUtils
.
hasText
(
simpleName
)
?
simpleName
:
exception
.
getClass
().
getName
());
}
return
EXCEPTION_NONE
;
}
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java
View file @
592754d8
...
...
@@ -136,7 +136,8 @@ public final class WebMvcTags {
public
static
Tag
exception
(
Throwable
exception
)
{
if
(
exception
!=
null
)
{
String
simpleName
=
exception
.
getClass
().
getSimpleName
();
return
Tag
.
of
(
"exception"
,
simpleName
.
isEmpty
()
?
exception
.
getClass
().
getName
()
:
simpleName
);
return
Tag
.
of
(
"exception"
,
StringUtils
.
hasText
(
simpleName
)
?
simpleName
:
exception
.
getClass
().
getName
());
}
return
EXCEPTION_NONE
;
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilterTests.java
View file @
592754d8
...
...
@@ -82,14 +82,12 @@ public class MetricsWebFilterTests {
@Test
public
void
filterAddsNonEmptyTagsToRegistryForAnonymousExceptions
()
{
final
Exception
anonymous
=
new
Exception
(
"test error"
)
{};
final
Exception
anonymous
=
new
Exception
(
"test error"
)
{
};
MockServerWebExchange
exchange
=
createExchange
(
"/projects/spring-boot"
,
"/projects/{project}"
);
this
.
webFilter
.
filter
(
exchange
,
(
serverWebExchange
)
->
Mono
.
error
(
anonymous
))
this
.
webFilter
.
filter
(
exchange
,
(
serverWebExchange
)
->
Mono
.
error
(
anonymous
))
.
onErrorResume
((
t
)
->
{
exchange
.
getResponse
().
setStatusCodeValue
(
500
);
return
exchange
.
getResponse
().
setComplete
();
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java
View file @
592754d8
...
...
@@ -189,15 +189,15 @@ public class WebMvcMetricsFilterTests {
}
@Test
public
void
anonymousError
()
throws
Exception
{
public
void
anonymousError
()
{
try
{
mvc
.
perform
(
get
(
"/api/c1/anonymousError/10"
));
}
catch
(
Throwable
ignore
)
{
this
.
mvc
.
perform
(
get
(
"/api/c1/anonymousError/10"
));
}
assertThat
(
this
.
registry
.
get
(
"http.server.requests"
).
tag
(
"uri"
,
"/api/c1/anonymousError/{id}"
).
timer
().
getId
()
.
getTag
(
"exception"
))
.
endsWith
(
"$1"
);
catch
(
Throwable
ignore
)
{
}
assertThat
(
this
.
registry
.
get
(
"http.server.requests"
)
.
tag
(
"uri"
,
"/api/c1/anonymousError/{id}"
).
timer
().
getId
()
.
getTag
(
"exception"
)).
endsWith
(
"$1"
);
}
@Test
...
...
@@ -454,8 +454,10 @@ public class WebMvcMetricsFilterTests {
@Timed
@GetMapping
(
"/anonymousError/{id}"
)
public
String
alwaysThrowsAnonymousException
(
@PathVariable
Long
id
)
throws
Exception
{
throw
new
Exception
(
"this exception won't have a simple class name"
)
{};
public
String
alwaysThrowsAnonymousException
(
@PathVariable
Long
id
)
throws
Exception
{
throw
new
Exception
(
"this exception won't have a simple class name"
)
{
};
}
@Timed
...
...
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