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
d3b3c8c6
Commit
d3b3c8c6
authored
Oct 08, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Honour management.metrics.web.server.auto-time-requests with WebFlux
Closes gh-13895
parent
1f34da90
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
WebFluxMetricsAutoConfiguration.java
...metrics/web/reactive/WebFluxMetricsAutoConfiguration.java
+2
-1
WebFluxMetricsAutoConfigurationTests.java
...cs/web/reactive/WebFluxMetricsAutoConfigurationTests.java
+13
-0
MetricsWebFilter.java
...actuate/metrics/web/reactive/server/MetricsWebFilter.java
+21
-1
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java
View file @
d3b3c8c6
...
@@ -66,7 +66,8 @@ public class WebFluxMetricsAutoConfiguration {
...
@@ -66,7 +66,8 @@ public class WebFluxMetricsAutoConfiguration {
public
MetricsWebFilter
webfluxMetrics
(
MeterRegistry
registry
,
public
MetricsWebFilter
webfluxMetrics
(
MeterRegistry
registry
,
WebFluxTagsProvider
tagConfigurer
)
{
WebFluxTagsProvider
tagConfigurer
)
{
return
new
MetricsWebFilter
(
registry
,
tagConfigurer
,
return
new
MetricsWebFilter
(
registry
,
tagConfigurer
,
this
.
properties
.
getWeb
().
getServer
().
getRequestsMetricName
());
this
.
properties
.
getWeb
().
getServer
().
getRequestsMetricName
(),
this
.
properties
.
getWeb
().
getServer
().
isAutoTimeRequests
());
}
}
@Bean
@Bean
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java
View file @
d3b3c8c6
...
@@ -98,6 +98,19 @@ public class WebFluxMetricsAutoConfigurationTests {
...
@@ -98,6 +98,19 @@ public class WebFluxMetricsAutoConfigurationTests {
});
});
}
}
@Test
public
void
metricsAreNotRecordedIfAutoTimeRequestsIsDisabled
()
{
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
WebFluxAutoConfiguration
.
class
))
.
withUserConfiguration
(
TestController
.
class
)
.
withPropertyValues
(
"management.metrics.web.server.auto-time-requests=false"
)
.
run
((
context
)
->
{
MeterRegistry
registry
=
getInitializedMeterRegistry
(
context
);
assertThat
(
registry
.
find
(
"http.server.requests"
).
meter
()).
isNull
();
});
}
private
MeterRegistry
getInitializedMeterRegistry
(
private
MeterRegistry
getInitializedMeterRegistry
(
AssertableReactiveWebApplicationContext
context
)
{
AssertableReactiveWebApplicationContext
context
)
{
WebTestClient
webTestClient
=
WebTestClient
.
bindToApplicationContext
(
context
)
WebTestClient
webTestClient
=
WebTestClient
.
bindToApplicationContext
(
context
)
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilter.java
View file @
d3b3c8c6
...
@@ -46,16 +46,36 @@ public class MetricsWebFilter implements WebFilter {
...
@@ -46,16 +46,36 @@ public class MetricsWebFilter implements WebFilter {
private
final
String
metricName
;
private
final
String
metricName
;
private
final
boolean
autoTimeRequests
;
/**
* Create a new {@code MetricsWebFilter}.
* @param registry the registry to which metrics are recorded
* @param tagsProvider provider for metrics tags
* @param metricName name of the metric to record
* @deprecated since 2.0.6 in favour of
* {@link #MetricsWebFilter(MeterRegistry, WebFluxTagsProvider, String, boolean)}
*/
@Deprecated
public
MetricsWebFilter
(
MeterRegistry
registry
,
WebFluxTagsProvider
tagsProvider
,
public
MetricsWebFilter
(
MeterRegistry
registry
,
WebFluxTagsProvider
tagsProvider
,
String
metricName
)
{
String
metricName
)
{
this
(
registry
,
tagsProvider
,
metricName
,
true
);
}
public
MetricsWebFilter
(
MeterRegistry
registry
,
WebFluxTagsProvider
tagsProvider
,
String
metricName
,
boolean
autoTimeRequests
)
{
this
.
registry
=
registry
;
this
.
registry
=
registry
;
this
.
tagsProvider
=
tagsProvider
;
this
.
tagsProvider
=
tagsProvider
;
this
.
metricName
=
metricName
;
this
.
metricName
=
metricName
;
this
.
autoTimeRequests
=
autoTimeRequests
;
}
}
@Override
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
WebFilterChain
chain
)
{
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
WebFilterChain
chain
)
{
return
chain
.
filter
(
exchange
).
compose
((
call
)
->
filter
(
exchange
,
call
));
if
(
this
.
autoTimeRequests
)
{
return
chain
.
filter
(
exchange
).
compose
((
call
)
->
filter
(
exchange
,
call
));
}
return
chain
.
filter
(
exchange
);
}
}
private
Publisher
<
Void
>
filter
(
ServerWebExchange
exchange
,
Mono
<
Void
>
call
)
{
private
Publisher
<
Void
>
filter
(
ServerWebExchange
exchange
,
Mono
<
Void
>
call
)
{
...
...
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