Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
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
openSource
spring-cloud-netflix
Commits
be140748
Commit
be140748
authored
Nov 11, 2015
by
Jon Schneider
Committed by
Spencer Gibb
Nov 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RestTemplate metrics collection join point now returns a value
parent
024d9946
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
8 deletions
+11
-8
MetricsInterceptorConfiguration.java
...loud/netflix/metrics/MetricsInterceptorConfiguration.java
+2
-2
RestTemplateUrlTemplateCapturingAspect.java
...tflix/metrics/RestTemplateUrlTemplateCapturingAspect.java
+2
-2
MetricsClientHttpRequestInterceptorTests.java
...lix/metrics/MetricsClientHttpRequestInterceptorTests.java
+7
-4
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/metrics/MetricsInterceptorConfiguration.java
View file @
be140748
...
...
@@ -39,13 +39,13 @@ public class MetricsInterceptorConfiguration {
@ConditionalOnWebApplication
static
class
MetricsWebResourceConfiguration
extends
WebMvcConfigurerAdapter
{
@Bean
MetricsHandlerInterceptor
s
pectator
MonitoringWebResourceInterceptor
()
{
MetricsHandlerInterceptor
s
ervo
MonitoringWebResourceInterceptor
()
{
return
new
MetricsHandlerInterceptor
();
}
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
s
pectator
MonitoringWebResourceInterceptor
());
registry
.
addInterceptor
(
s
ervo
MonitoringWebResourceInterceptor
());
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/metrics/RestTemplateUrlTemplateCapturingAspect.java
View file @
be140748
...
...
@@ -26,11 +26,11 @@ import org.aspectj.lang.annotation.Aspect;
@Aspect
public
class
RestTemplateUrlTemplateCapturingAspect
{
@Around
(
"execution(* org.springframework.web.client.RestOperations+.*(String, ..))"
)
void
captureUrlTemplate
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
Object
captureUrlTemplate
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
try
{
String
urlTemplate
=
(
String
)
joinPoint
.
getArgs
()[
0
];
RestTemplateUrlTemplateHolder
.
setRestTemplateUrlTemplate
(
urlTemplate
);
joinPoint
.
proceed
();
return
joinPoint
.
proceed
();
}
finally
{
RestTemplateUrlTemplateHolder
.
clear
();
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/metrics/MetricsClientHttpRequestInterceptorTests.java
View file @
be140748
...
...
@@ -13,7 +13,8 @@
package
org
.
springframework
.
cloud
.
netflix
.
metrics
;
import
org.junit.Assert
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -62,8 +63,8 @@ public class MetricsClientHttpRequestInterceptorTests {
MockRestServiceServer
mockServer
=
MockRestServiceServer
.
createServer
(
restTemplate
);
mockServer
.
expect
(
MockRestRequestMatchers
.
requestTo
(
"/test/123"
))
.
andExpect
(
MockRestRequestMatchers
.
method
(
HttpMethod
.
GET
))
.
andRespond
(
MockRestResponseCreators
.
withSuccess
(
"
{\"status\" : \"OK\"}
"
,
MediaType
.
APPLICATION_JSON
));
restTemplate
.
getForObject
(
"/test/{id}"
,
String
.
class
,
123
);
.
andRespond
(
MockRestResponseCreators
.
withSuccess
(
"
OK
"
,
MediaType
.
APPLICATION_JSON
));
String
s
=
restTemplate
.
getForObject
(
"/test/{id}"
,
String
.
class
,
123
);
MonitorConfig
.
Builder
builder
=
new
MonitorConfig
.
Builder
(
"metricName"
)
.
withTag
(
"method"
,
"GET"
)
...
...
@@ -73,7 +74,9 @@ public class MetricsClientHttpRequestInterceptorTests {
BasicTimer
timer
=
servoMonitorCache
.
getTimer
(
builder
.
build
());
Assert
.
assertEquals
(
1L
,
(
long
)
timer
.
getCount
());
assertEquals
(
1L
,
(
long
)
timer
.
getCount
());
assertEquals
(
"OK"
,
s
);
mockServer
.
verify
();
}
}
...
...
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