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
7d78a3c3
Commit
7d78a3c3
authored
Dec 16, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #724 from jkschneider/metric-poller
Add Servo metric poller and @EnableAtlas test
parents
3f45391d
1cd363f3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
6 deletions
+87
-6
AtlasAutoConfiguration.java
...k/cloud/netflix/metrics/atlas/AtlasAutoConfiguration.java
+11
-0
AtlasExporterTests.java
...ework/cloud/netflix/metrics/atlas/AtlasExporterTests.java
+76
-0
SpectatorMetricsAutoConfiguration.java
.../metrics/spectator/SpectatorMetricsAutoConfiguration.java
+0
-6
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/metrics/atlas/AtlasAutoConfiguration.java
View file @
7d78a3c3
...
...
@@ -20,11 +20,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.actuate.metrics.export.Exporter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.cloud.netflix.metrics.servo.ServoMetricsAutoConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.web.client.RestTemplate
;
import
com.netflix.servo.MonitorRegistry
;
import
com.netflix.servo.publish.MetricPoller
;
import
com.netflix.servo.publish.MonitorRegistryMetricPoller
;
import
com.netflix.servo.tag.BasicTagList
;
/**
...
...
@@ -34,6 +38,7 @@ import com.netflix.servo.tag.BasicTagList;
*/
@Configuration
@ConditionalOnClass
(
AtlasMetricObserver
.
class
)
@Import
(
ServoMetricsAutoConfiguration
.
class
)
public
class
AtlasAutoConfiguration
{
@Autowired
(
required
=
false
)
private
Collection
<
AtlasTagProvider
>
tagProviders
;
...
...
@@ -60,6 +65,12 @@ public class AtlasAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public
MetricPoller
metricPoller
(
MonitorRegistry
monitorRegistry
)
{
return
new
MonitorRegistryMetricPoller
(
monitorRegistry
);
}
@Bean
@ConditionalOnMissingBean
public
Exporter
exporter
(
AtlasMetricObserver
observer
,
MetricPoller
poller
)
{
return
new
AtlasExporter
(
observer
,
poller
);
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/metrics/atlas/AtlasExporterTests.java
0 → 100644
View file @
7d78a3c3
/*
* Copyright 2013-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package
org
.
springframework
.
cloud
.
netflix
.
metrics
.
atlas
;
import
java.util.Properties
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.support.PropertySourcesPlaceholderConfigurer
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.web.client.MockRestServiceServer
;
import
org.springframework.test.web.client.match.MockRestRequestMatchers
;
import
org.springframework.test.web.client.response.MockRestResponseCreators
;
import
org.springframework.web.client.RestTemplate
;
import
com.netflix.servo.monitor.DynamicCounter
;
/**
* @author Jon Schneider
*/
@SpringApplicationConfiguration
(
AtlasExporterConfiguration
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
public
class
AtlasExporterTests
{
@Autowired
RestTemplate
restTemplate
;
@Autowired
AtlasExporter
atlasExporter
;
@Test
public
void
exportMetricsAtPeriodicIntervals
()
{
MockRestServiceServer
mockServer
=
MockRestServiceServer
.
createServer
(
restTemplate
);
mockServer
.
expect
(
MockRestRequestMatchers
.
requestTo
(
"atlas/api/v1/publish"
))
.
andExpect
(
MockRestRequestMatchers
.
method
(
HttpMethod
.
POST
))
.
andRespond
(
MockRestResponseCreators
.
withSuccess
(
"{\"status\" : \"OK\"}"
,
MediaType
.
APPLICATION_JSON
));
DynamicCounter
.
increment
(
"counterThatWillBeSentToAtlas"
);
atlasExporter
.
export
();
mockServer
.
verify
();
}
}
@EnableAutoConfiguration
@Configuration
@EnableAtlas
class
AtlasExporterConfiguration
{
@Bean
public
static
PropertySourcesPlaceholderConfigurer
properties
()
throws
Exception
{
final
PropertySourcesPlaceholderConfigurer
config
=
new
PropertySourcesPlaceholderConfigurer
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"netflix.atlas.uri"
,
"atlas"
);
config
.
setProperties
(
properties
);
return
config
;
}
}
\ No newline at end of file
spring-cloud-netflix-spectator/src/main/java/org/springframework/cloud/netflix/metrics/spectator/SpectatorMetricsAutoConfiguration.java
View file @
7d78a3c3
...
...
@@ -73,12 +73,6 @@ public class SpectatorMetricsAutoConfiguration {
}
@Bean
@ConditionalOnMissingBean
(
MetricPoller
.
class
)
MetricPoller
metricPoller
()
{
return
new
MonitorRegistryMetricPoller
();
}
@Bean
@ConditionalOnMissingBean
public
SpectatorMetricServices
spectatorMetricServices
(
Registry
metricRegistry
)
{
return
new
SpectatorMetricServices
(
metricRegistry
);
...
...
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