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
713e6b84
Commit
713e6b84
authored
Nov 12, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #639 from jkschneider/metrics-aop-fix
* metrics-aop-fix: RestTemplate metrics collection join point now returns a value
parents
024d9946
be140748
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 @
713e6b84
...
@@ -39,13 +39,13 @@ public class MetricsInterceptorConfiguration {
...
@@ -39,13 +39,13 @@ public class MetricsInterceptorConfiguration {
@ConditionalOnWebApplication
@ConditionalOnWebApplication
static
class
MetricsWebResourceConfiguration
extends
WebMvcConfigurerAdapter
{
static
class
MetricsWebResourceConfiguration
extends
WebMvcConfigurerAdapter
{
@Bean
@Bean
MetricsHandlerInterceptor
s
pectator
MonitoringWebResourceInterceptor
()
{
MetricsHandlerInterceptor
s
ervo
MonitoringWebResourceInterceptor
()
{
return
new
MetricsHandlerInterceptor
();
return
new
MetricsHandlerInterceptor
();
}
}
@Override
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
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 @
713e6b84
...
@@ -26,11 +26,11 @@ import org.aspectj.lang.annotation.Aspect;
...
@@ -26,11 +26,11 @@ import org.aspectj.lang.annotation.Aspect;
@Aspect
@Aspect
public
class
RestTemplateUrlTemplateCapturingAspect
{
public
class
RestTemplateUrlTemplateCapturingAspect
{
@Around
(
"execution(* org.springframework.web.client.RestOperations+.*(String, ..))"
)
@Around
(
"execution(* org.springframework.web.client.RestOperations+.*(String, ..))"
)
void
captureUrlTemplate
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
Object
captureUrlTemplate
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
try
{
try
{
String
urlTemplate
=
(
String
)
joinPoint
.
getArgs
()[
0
];
String
urlTemplate
=
(
String
)
joinPoint
.
getArgs
()[
0
];
RestTemplateUrlTemplateHolder
.
setRestTemplateUrlTemplate
(
urlTemplate
);
RestTemplateUrlTemplateHolder
.
setRestTemplateUrlTemplate
(
urlTemplate
);
joinPoint
.
proceed
();
return
joinPoint
.
proceed
();
}
}
finally
{
finally
{
RestTemplateUrlTemplateHolder
.
clear
();
RestTemplateUrlTemplateHolder
.
clear
();
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/metrics/MetricsClientHttpRequestInterceptorTests.java
View file @
713e6b84
...
@@ -13,7 +13,8 @@
...
@@ -13,7 +13,8 @@
package
org
.
springframework
.
cloud
.
netflix
.
metrics
;
package
org
.
springframework
.
cloud
.
netflix
.
metrics
;
import
org.junit.Assert
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -62,8 +63,8 @@ public class MetricsClientHttpRequestInterceptorTests {
...
@@ -62,8 +63,8 @@ public class MetricsClientHttpRequestInterceptorTests {
MockRestServiceServer
mockServer
=
MockRestServiceServer
.
createServer
(
restTemplate
);
MockRestServiceServer
mockServer
=
MockRestServiceServer
.
createServer
(
restTemplate
);
mockServer
.
expect
(
MockRestRequestMatchers
.
requestTo
(
"/test/123"
))
mockServer
.
expect
(
MockRestRequestMatchers
.
requestTo
(
"/test/123"
))
.
andExpect
(
MockRestRequestMatchers
.
method
(
HttpMethod
.
GET
))
.
andExpect
(
MockRestRequestMatchers
.
method
(
HttpMethod
.
GET
))
.
andRespond
(
MockRestResponseCreators
.
withSuccess
(
"
{\"status\" : \"OK\"}
"
,
MediaType
.
APPLICATION_JSON
));
.
andRespond
(
MockRestResponseCreators
.
withSuccess
(
"
OK
"
,
MediaType
.
APPLICATION_JSON
));
restTemplate
.
getForObject
(
"/test/{id}"
,
String
.
class
,
123
);
String
s
=
restTemplate
.
getForObject
(
"/test/{id}"
,
String
.
class
,
123
);
MonitorConfig
.
Builder
builder
=
new
MonitorConfig
.
Builder
(
"metricName"
)
MonitorConfig
.
Builder
builder
=
new
MonitorConfig
.
Builder
(
"metricName"
)
.
withTag
(
"method"
,
"GET"
)
.
withTag
(
"method"
,
"GET"
)
...
@@ -73,7 +74,9 @@ public class MetricsClientHttpRequestInterceptorTests {
...
@@ -73,7 +74,9 @@ public class MetricsClientHttpRequestInterceptorTests {
BasicTimer
timer
=
servoMonitorCache
.
getTimer
(
builder
.
build
());
BasicTimer
timer
=
servoMonitorCache
.
getTimer
(
builder
.
build
());
Assert
.
assertEquals
(
1L
,
(
long
)
timer
.
getCount
());
assertEquals
(
1L
,
(
long
)
timer
.
getCount
());
assertEquals
(
"OK"
,
s
);
mockServer
.
verify
();
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