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
0b689a5b
Commit
0b689a5b
authored
Jan 27, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish MetricsFilter registration async support
Closes gh-11348
parent
b6af06a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
16 deletions
+22
-16
MetricsAutoConfigurationIntegrationTests.java
...ure/metrics/MetricsAutoConfigurationIntegrationTests.java
+22
-16
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationIntegrationTests.java
View file @
0b689a5b
...
@@ -119,18 +119,18 @@ public class MetricsAutoConfigurationIntegrationTests {
...
@@ -119,18 +119,18 @@ public class MetricsAutoConfigurationIntegrationTests {
}
}
@Test
@Test
public
void
asyncRequestMappingIsInstrumented
()
throws
InterruptedException
,
BrokenBarrierException
{
public
void
asyncRequestMappingIsInstrumented
()
Thread
backgroundRequest
=
new
Thread
(()
->
this
.
loopback
.
getForObject
(
"/api/async"
,
String
.
class
));
throws
InterruptedException
,
BrokenBarrierException
{
Thread
backgroundRequest
=
new
Thread
(
()
->
this
.
loopback
.
getForObject
(
"/api/async"
,
String
.
class
));
backgroundRequest
.
start
();
backgroundRequest
.
start
();
this
.
cyclicBarrier
.
await
();
this
.
cyclicBarrier
.
await
();
MockClock
.
clock
(
this
.
registry
).
addSeconds
(
2
);
MockClock
.
clock
(
this
.
registry
).
addSeconds
(
2
);
this
.
cyclicBarrier
.
await
();
this
.
cyclicBarrier
.
await
();
backgroundRequest
.
join
();
backgroundRequest
.
join
();
assertThat
(
this
.
registry
.
find
(
"http.server.requests"
).
tags
(
"uri"
,
"/api/async"
)
assertThat
(
this
.
registry
.
find
(
"http.server.requests"
)
.
timer
()).
matches
(
t
->
t
.
count
()
==
1
)
.
tags
(
"uri"
,
"/api/async"
).
timer
())
.
matches
(
t
->
t
.
totalTime
(
TimeUnit
.
SECONDS
)
==
2
);
.
matches
(
t
->
t
.
count
()
==
1
)
.
matches
(
t
->
t
.
totalTime
(
TimeUnit
.
SECONDS
)
==
2
);
}
}
@Configuration
@Configuration
...
@@ -156,10 +156,12 @@ public class MetricsAutoConfigurationIntegrationTests {
...
@@ -156,10 +156,12 @@ public class MetricsAutoConfigurationIntegrationTests {
public
CyclicBarrier
cyclicBarrier
()
{
public
CyclicBarrier
cyclicBarrier
()
{
return
new
CyclicBarrier
(
2
);
return
new
CyclicBarrier
(
2
);
}
}
}
}
@RestController
@RestController
static
class
PersonController
{
static
class
PersonController
{
private
final
CyclicBarrier
cyclicBarrier
;
private
final
CyclicBarrier
cyclicBarrier
;
PersonController
(
CyclicBarrier
cyclicBarrier
)
{
PersonController
(
CyclicBarrier
cyclicBarrier
)
{
...
@@ -172,18 +174,22 @@ public class MetricsAutoConfigurationIntegrationTests {
...
@@ -172,18 +174,22 @@ public class MetricsAutoConfigurationIntegrationTests {
}
}
@GetMapping
(
"/api/async"
)
@GetMapping
(
"/api/async"
)
CompletableFuture
<
String
>
asyncHello
()
throws
BrokenBarrierException
,
InterruptedException
{
CompletableFuture
<
String
>
asyncHello
()
throws
BrokenBarrierException
,
InterruptedException
{
this
.
cyclicBarrier
.
await
();
this
.
cyclicBarrier
.
await
();
return
CompletableFuture
.
supplyAsync
(()
->
{
return
CompletableFuture
.
supplyAsync
(
this
::
awaitAndHello
);
try
{
}
this
.
cyclicBarrier
.
await
();
}
private
String
awaitAndHello
()
{
catch
(
InterruptedException
|
BrokenBarrierException
e
)
{
try
{
throw
new
RuntimeException
(
e
);
this
.
cyclicBarrier
.
await
();
}
return
"async-hello"
;
return
"async-hello"
;
});
}
catch
(
InterruptedException
|
BrokenBarrierException
ex
)
{
throw
new
RuntimeException
(
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