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
0669f560
Commit
0669f560
authored
Jan 18, 2021
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-24873
parents
c6ce97b8
59b01324
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
MetricsClientHttpRequestInterceptor.java
...trics/web/client/MetricsClientHttpRequestInterceptor.java
+12
-3
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/MetricsClientHttpRequestInterceptor.java
View file @
0669f560
/*
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
@@ -25,6 +25,8 @@ import java.util.concurrent.TimeUnit;
...
@@ -25,6 +25,8 @@ import java.util.concurrent.TimeUnit;
import
io.micrometer.core.instrument.MeterRegistry
;
import
io.micrometer.core.instrument.MeterRegistry
;
import
io.micrometer.core.instrument.Timer
;
import
io.micrometer.core.instrument.Timer
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.boot.actuate.metrics.AutoTimer
;
import
org.springframework.boot.actuate.metrics.AutoTimer
;
import
org.springframework.core.NamedThreadLocal
;
import
org.springframework.core.NamedThreadLocal
;
...
@@ -43,6 +45,8 @@ import org.springframework.web.util.UriTemplateHandler;
...
@@ -43,6 +45,8 @@ import org.springframework.web.util.UriTemplateHandler;
*/
*/
class
MetricsClientHttpRequestInterceptor
implements
ClientHttpRequestInterceptor
{
class
MetricsClientHttpRequestInterceptor
implements
ClientHttpRequestInterceptor
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
MetricsClientHttpRequestInterceptor
.
class
);
private
static
final
ThreadLocal
<
Deque
<
String
>>
urlTemplate
=
new
UrlTemplateThreadLocal
();
private
static
final
ThreadLocal
<
Deque
<
String
>>
urlTemplate
=
new
UrlTemplateThreadLocal
();
private
final
MeterRegistry
meterRegistry
;
private
final
MeterRegistry
meterRegistry
;
...
@@ -82,8 +86,13 @@ class MetricsClientHttpRequestInterceptor implements ClientHttpRequestIntercepto
...
@@ -82,8 +86,13 @@ class MetricsClientHttpRequestInterceptor implements ClientHttpRequestIntercepto
return
response
;
return
response
;
}
}
finally
{
finally
{
getTimeBuilder
(
request
,
response
).
register
(
this
.
meterRegistry
).
record
(
System
.
nanoTime
()
-
startTime
,
try
{
TimeUnit
.
NANOSECONDS
);
getTimeBuilder
(
request
,
response
).
register
(
this
.
meterRegistry
).
record
(
System
.
nanoTime
()
-
startTime
,
TimeUnit
.
NANOSECONDS
);
}
catch
(
Exception
ex
)
{
logger
.
info
(
"Failed to record metrics."
,
ex
);
}
if
(
urlTemplate
.
get
().
isEmpty
())
{
if
(
urlTemplate
.
get
().
isEmpty
())
{
urlTemplate
.
remove
();
urlTemplate
.
remove
();
}
}
...
...
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