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
10643b77
Commit
10643b77
authored
Feb 04, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Stop time web metrics when autotime is disabled"
See gh-19981
parent
e323e05e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
13 deletions
+14
-13
TestController.java
...oot/actuate/autoconfigure/metrics/web/TestController.java
+2
-2
WebMvcMetricsAutoConfigurationTests.java
...rics/web/servlet/WebMvcMetricsAutoConfigurationTests.java
+6
-5
WebMvcMetricsFilter.java
...boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java
+6
-6
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/TestController.java
View file @
10643b77
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -49,7 +49,7 @@ public class TestController {
...
@@ -49,7 +49,7 @@ public class TestController {
@Timed
@Timed
@GetMapping
(
"test3"
)
@GetMapping
(
"test3"
)
public
String
test3
()
{
public
String
test3
()
{
return
"test
2
"
;
return
"test
3
"
;
}
}
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfigurationTests.java
View file @
10643b77
...
@@ -71,8 +71,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
...
@@ -71,8 +71,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ExtendWith
(
OutputCaptureExtension
.
class
)
@ExtendWith
(
OutputCaptureExtension
.
class
)
class
WebMvcMetricsAutoConfigurationTests
{
class
WebMvcMetricsAutoConfigurationTests
{
private
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
().
with
(
MetricsRun
.
simple
()
)
private
final
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
(
)
.
withConfiguration
(
AutoConfigurations
.
of
(
WebMvcMetricsAutoConfiguration
.
class
));
.
with
(
MetricsRun
.
simple
()).
with
Configuration
(
AutoConfigurations
.
of
(
WebMvcMetricsAutoConfiguration
.
class
));
@Test
@Test
void
backsOffWhenMeterRegistryIsMissing
()
{
void
backsOffWhenMeterRegistryIsMissing
()
{
...
@@ -183,11 +183,12 @@ class WebMvcMetricsAutoConfigurationTests {
...
@@ -183,11 +183,12 @@ class WebMvcMetricsAutoConfigurationTests {
.
contains
(
LongTaskTimingHandlerInterceptor
.
class
));
.
contains
(
LongTaskTimingHandlerInterceptor
.
class
));
}
}
private
MeterRegistry
getInitializedMeterRegistry
(
AssertableWebApplicationContext
context
)
throws
Exception
{
return
getInitializedMeterRegistry
(
context
,
"/test0"
,
"/test1"
,
"/test2"
);
}
private
MeterRegistry
getInitializedMeterRegistry
(
AssertableWebApplicationContext
context
,
String
...
urls
)
private
MeterRegistry
getInitializedMeterRegistry
(
AssertableWebApplicationContext
context
,
String
...
urls
)
throws
Exception
{
throws
Exception
{
if
(
urls
.
length
==
0
)
{
urls
=
new
String
[]
{
"/test0"
,
"/test1"
,
"/test2"
};
}
assertThat
(
context
).
hasSingleBean
(
FilterRegistrationBean
.
class
);
assertThat
(
context
).
hasSingleBean
(
FilterRegistrationBean
.
class
);
Filter
filter
=
context
.
getBean
(
FilterRegistrationBean
.
class
).
getFilter
();
Filter
filter
=
context
.
getBean
(
FilterRegistrationBean
.
class
).
getFilter
();
assertThat
(
filter
).
isInstanceOf
(
WebMvcMetricsFilter
.
class
);
assertThat
(
filter
).
isInstanceOf
(
WebMvcMetricsFilter
.
class
);
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java
View file @
10643b77
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -144,11 +144,11 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
...
@@ -144,11 +144,11 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
Builder
builder
=
this
.
autoTimer
.
builder
(
this
.
metricName
);
Builder
builder
=
this
.
autoTimer
.
builder
(
this
.
metricName
);
timerSample
.
stop
(
getTimer
(
builder
,
handler
,
request
,
response
,
exception
));
timerSample
.
stop
(
getTimer
(
builder
,
handler
,
request
,
response
,
exception
));
}
}
return
;
}
else
{
}
for
(
Timed
annotation
:
annotations
)
{
for
(
Timed
annotation
:
annotations
)
{
Builder
builder
=
Timer
.
builder
(
annotation
,
this
.
metricName
);
Builder
builder
=
Timer
.
builder
(
annotation
,
this
.
metricName
);
timerSample
.
stop
(
getTimer
(
builder
,
handler
,
request
,
response
,
exception
)
);
timerSample
.
stop
(
getTimer
(
builder
,
handler
,
request
,
response
,
exception
));
}
}
}
}
}
...
...
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