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
270d5e32
Commit
270d5e32
authored
May 11, 2015
by
Dave Syer
Committed by
Andy Wilkinson
May 13, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add @ActuatorMetricRepository to qualify the "native" repository
Primarily when it is needed for metric export.
parent
2f2750e7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
11 deletions
+60
-11
ActuatorMetricRepository.java
.../boot/actuate/autoconfigure/ActuatorMetricRepository.java
+42
-0
MetricRepositoryAutoConfiguration.java
...uate/autoconfigure/MetricRepositoryAutoConfiguration.java
+9
-9
PublicMetricsAutoConfiguration.java
...actuate/autoconfigure/PublicMetricsAutoConfiguration.java
+1
-0
MetricsEndpoint.java
...pringframework/boot/actuate/endpoint/MetricsEndpoint.java
+7
-2
application.properties
...e-metrics-redis/src/main/resources/application.properties
+1
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ActuatorMetricRepository.java
0 → 100644
View file @
270d5e32
/*
* Copyright 2012-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
.
boot
.
actuate
.
autoconfigure
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
org.springframework.beans.factory.annotation.Qualifier
;
/**
* Qualifier annotation for a metric repository that is used by the actuator (to
* distinguish it from others that might be installed by the user).
*
* @author Dave Syer
*/
@Qualifier
@Target
({
ElementType
.
FIELD
,
ElementType
.
METHOD
,
ElementType
.
PARAMETER
,
ElementType
.
TYPE
,
ElementType
.
ANNOTATION_TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Inherited
@Documented
public
@interface
ActuatorMetricRepository
{
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricRepositoryAutoConfiguration.java
View file @
270d5e32
...
...
@@ -21,7 +21,6 @@ import java.util.HashMap;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.actuate.metrics.CounterService
;
import
org.springframework.boot.actuate.metrics.GaugeService
;
import
org.springframework.boot.actuate.metrics.buffer.BufferCounterService
;
...
...
@@ -48,7 +47,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.messaging.MessageChannel
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
...
...
@@ -96,10 +94,11 @@ public class MetricRepositoryAutoConfiguration {
@Configuration
@ConditionalOnJava
(
value
=
JavaVersion
.
EIGHT
,
range
=
Range
.
OLDER_THAN
)
@ConditionalOnMissingBean
(
MetricRepository
.
class
)
@ConditionalOnMissingBean
(
GaugeService
.
class
)
static
class
LegacyMetricServicesConfiguration
{
@Autowired
@ActuatorMetricRepository
private
MetricWriter
writer
;
@Bean
...
...
@@ -118,7 +117,7 @@ public class MetricRepositoryAutoConfiguration {
@Configuration
@ConditionalOnJava
(
value
=
JavaVersion
.
EIGHT
)
@ConditionalOnMissingBean
(
MetricRepository
.
class
)
@ConditionalOnMissingBean
(
GaugeService
.
class
)
static
class
FastMetricServicesConfiguration
{
@Bean
...
...
@@ -134,9 +133,9 @@ public class MetricRepositoryAutoConfiguration {
}
@Bean
@
Prima
ry
@
ActuatorMetricReposito
ry
@ConditionalOnMissingBean
public
BufferMetricReader
m
etricReader
(
CounterBuffers
counters
,
public
BufferMetricReader
actuatorM
etricReader
(
CounterBuffers
counters
,
GaugeBuffers
gauges
)
{
return
new
BufferMetricReader
(
counters
,
gauges
);
}
...
...
@@ -160,7 +159,7 @@ public class MetricRepositoryAutoConfiguration {
static
class
LegacyMetricRepositoryConfiguration
{
@Bean
@
Prima
ry
@
ActuatorMetricReposito
ry
public
InMemoryMetricRepository
actuatorMetricRepository
()
{
return
new
InMemoryMetricRepository
();
}
...
...
@@ -179,12 +178,13 @@ public class MetricRepositoryAutoConfiguration {
private
MetricExportProperties
metrics
;
@Autowired
(
required
=
false
)
@
Qualifier
(
"actuatorMetricRepository"
)
@
ActuatorMetricRepository
private
MetricWriter
actuatorMetricRepository
;
@Bean
@ConditionalOnMissingBean
public
MetricExporters
metricWritersMetricExporter
(
MetricReader
reader
)
{
public
MetricExporters
metricWritersMetricExporter
(
@ActuatorMetricRepository
MetricReader
reader
)
{
Map
<
String
,
MetricWriter
>
writers
=
new
HashMap
<
String
,
MetricWriter
>(
this
.
writers
);
if
(
this
.
actuatorMetricRepository
!=
null
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java
View file @
270d5e32
...
...
@@ -60,6 +60,7 @@ import org.springframework.context.annotation.Configuration;
public
class
PublicMetricsAutoConfiguration
{
@Autowired
(
required
=
false
)
@ActuatorMetricRepository
private
MetricReader
metricReader
=
new
InMemoryMetricRepository
();
@Bean
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/MetricsEndpoint.java
View file @
270d5e32
...
...
@@ -62,8 +62,13 @@ public class MetricsEndpoint extends AbstractEndpoint<Map<String, Object>> {
public
Map
<
String
,
Object
>
invoke
()
{
Map
<
String
,
Object
>
result
=
new
LinkedHashMap
<
String
,
Object
>();
for
(
PublicMetrics
publicMetric
:
this
.
publicMetrics
)
{
for
(
Metric
<?>
metric
:
publicMetric
.
metrics
())
{
result
.
put
(
metric
.
getName
(),
metric
.
getValue
());
try
{
for
(
Metric
<?>
metric
:
publicMetric
.
metrics
())
{
result
.
put
(
metric
.
getName
(),
metric
.
getValue
());
}
}
catch
(
Exception
e
)
{
// Could not evaluate metrics
}
}
return
result
;
...
...
spring-boot-samples/spring-boot-sample-metrics-redis/src/main/resources/application.properties
View file @
270d5e32
service.name
:
Phil
redis.metrics.export.prefix
:
metrics.sample.${random.value:0000}.${spring.application.name:application}
redis.metrics.export.key
:
keys.metrics.sample
spring.jmx.default-domain
:
org.springframework.boot
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