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
331c7a1c
Commit
331c7a1c
authored
Nov 20, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make handler Object available to WebMvcTagsProvider.httpRequestTags
Closes gh-11088
parent
417c9830
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
6 deletions
+11
-6
DefaultWebMvcTagsProvider.java
...ctuate/metrics/web/servlet/DefaultWebMvcTagsProvider.java
+2
-1
WebMvcMetrics.java
...ework/boot/actuate/metrics/web/servlet/WebMvcMetrics.java
+6
-3
WebMvcTagsProvider.java
.../boot/actuate/metrics/web/servlet/WebMvcTagsProvider.java
+3
-2
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/DefaultWebMvcTagsProvider.java
View file @
331c7a1c
...
@@ -45,12 +45,13 @@ public class DefaultWebMvcTagsProvider implements WebMvcTagsProvider {
...
@@ -45,12 +45,13 @@ public class DefaultWebMvcTagsProvider implements WebMvcTagsProvider {
/**
/**
* Supplies default tags to the Web MVC server programming model.
* Supplies default tags to the Web MVC server programming model.
* @param request The HTTP request.
* @param request The HTTP request.
* @param handler the Spring MVC handler for the request
* @param response The HTTP response.
* @param response The HTTP response.
* @param ex The current exception, if any
* @param ex The current exception, if any
* @return A set of tags added to every Spring MVC HTTP request.
* @return A set of tags added to every Spring MVC HTTP request.
*/
*/
@Override
@Override
public
Iterable
<
Tag
>
httpRequestTags
(
HttpServletRequest
request
,
public
Iterable
<
Tag
>
httpRequestTags
(
HttpServletRequest
request
,
Object
handler
,
HttpServletResponse
response
,
Throwable
ex
)
{
HttpServletResponse
response
,
Throwable
ex
)
{
return
Arrays
.
asList
(
WebMvcTags
.
method
(
request
),
return
Arrays
.
asList
(
WebMvcTags
.
method
(
request
),
WebMvcTags
.
uri
(
request
,
response
),
WebMvcTags
.
exception
(
ex
),
WebMvcTags
.
uri
(
request
,
response
),
WebMvcTags
.
exception
(
ex
),
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetrics.java
View file @
331c7a1c
...
@@ -45,6 +45,7 @@ import org.springframework.util.ObjectUtils;
...
@@ -45,6 +45,7 @@ import org.springframework.util.ObjectUtils;
import
org.springframework.web.context.request.RequestAttributes
;
import
org.springframework.web.context.request.RequestAttributes
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.servlet.mvc.ParameterizableViewController
;
import
org.springframework.web.servlet.resource.ResourceHttpRequestHandler
;
import
org.springframework.web.servlet.resource.ResourceHttpRequestHandler
;
/**
/**
...
@@ -144,16 +145,18 @@ public class WebMvcMetrics {
...
@@ -144,16 +145,18 @@ public class WebMvcMetrics {
Throwable
thrown
)
{
Throwable
thrown
)
{
// record Timer values
// record Timer values
timed
(
handler
).
forEach
((
config
)
->
{
timed
(
handler
).
forEach
((
config
)
->
{
Timer
.
Builder
builder
=
getTimerBuilder
(
request
,
response
,
thrown
,
config
);
Timer
.
Builder
builder
=
getTimerBuilder
(
request
,
handler
,
response
,
thrown
,
config
);
long
amount
=
endTime
-
startTime
;
long
amount
=
endTime
-
startTime
;
builder
.
register
(
this
.
registry
).
record
(
amount
,
TimeUnit
.
NANOSECONDS
);
builder
.
register
(
this
.
registry
).
record
(
amount
,
TimeUnit
.
NANOSECONDS
);
});
});
}
}
private
Timer
.
Builder
getTimerBuilder
(
HttpServletRequest
request
,
private
Timer
.
Builder
getTimerBuilder
(
HttpServletRequest
request
,
Object
handler
,
HttpServletResponse
response
,
Throwable
thrown
,
TimerConfig
config
)
{
HttpServletResponse
response
,
Throwable
thrown
,
TimerConfig
config
)
{
Timer
.
Builder
builder
=
Timer
.
builder
(
config
.
getName
())
Timer
.
Builder
builder
=
Timer
.
builder
(
config
.
getName
())
.
tags
(
this
.
tagsProvider
.
httpRequestTags
(
request
,
response
,
thrown
))
.
tags
(
this
.
tagsProvider
.
httpRequestTags
(
request
,
handler
,
response
,
thrown
))
.
tags
(
config
.
getExtraTags
()).
description
(
"Timer of servlet request"
)
.
tags
(
config
.
getExtraTags
()).
description
(
"Timer of servlet request"
)
.
publishPercentileHistogram
(
config
.
isHistogram
());
.
publishPercentileHistogram
(
config
.
isHistogram
());
if
(
config
.
getPercentiles
().
length
>
0
)
{
if
(
config
.
getPercentiles
().
length
>
0
)
{
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTagsProvider.java
View file @
331c7a1c
...
@@ -41,13 +41,14 @@ public interface WebMvcTagsProvider {
...
@@ -41,13 +41,14 @@ public interface WebMvcTagsProvider {
/**
/**
* Provides tags to be associated with metrics for the given {@code request} and
* Provides tags to be associated with metrics for the given {@code request} and
* {@code response} exchange.
* {@code response} exchange.
The request was handled by the given {@code handler}.
* @param request the request
* @param request the request
* @param handler the handler
* @param response the response
* @param response the response
* @param ex the current exception, if any
* @param ex the current exception, if any
* @return tags to associate with metrics for the request and response exchange
* @return tags to associate with metrics for the request and response exchange
*/
*/
Iterable
<
Tag
>
httpRequestTags
(
HttpServletRequest
request
,
Iterable
<
Tag
>
httpRequestTags
(
HttpServletRequest
request
,
Object
handler
,
HttpServletResponse
response
,
Throwable
ex
);
HttpServletResponse
response
,
Throwable
ex
);
}
}
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