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
b87e02dd
Commit
b87e02dd
authored
Dec 21, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish Spring Integration metrics support
See gh-7722
parent
d69e43b4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
78 additions
and
59 deletions
+78
-59
pom.xml
spring-boot-actuator/pom.xml
+5
-5
PublicMetricsAutoConfiguration.java
...actuate/autoconfigure/PublicMetricsAutoConfiguration.java
+1
-3
SpringIntegrationMetricReader.java
...te/metrics/integration/SpringIntegrationMetricReader.java
+60
-41
PublicMetricsAutoConfigurationTests.java
...te/autoconfigure/PublicMetricsAutoConfigurationTests.java
+1
-1
SpringIntegrationMetricReaderNoJmxTests.java
.../integration/SpringIntegrationMetricReaderNoJmxTests.java
+1
-2
SpringIntegrationMetricReaderTests.java
...trics/integration/SpringIntegrationMetricReaderTests.java
+2
-1
IntegrationAutoConfiguration.java
...toconfigure/integration/IntegrationAutoConfiguration.java
+3
-4
IntegrationAutoConfigurationTests.java
...figure/integration/IntegrationAutoConfigurationTests.java
+5
-2
No files found.
spring-boot-actuator/pom.xml
View file @
b87e02dd
...
...
@@ -358,6 +358,11 @@
<artifactId>
spring-data-rest-webmvc
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-jmx
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<artifactId>
spring-security-test
</artifactId>
...
...
@@ -368,10 +373,5 @@
<artifactId>
snakeyaml
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-jmx
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java
View file @
b87e02dd
...
...
@@ -148,9 +148,7 @@ public class PublicMetricsAutoConfiguration {
static
class
IntegrationMetricsConfiguration
{
@Bean
(
name
=
IntegrationManagementConfigurer
.
MANAGEMENT_CONFIGURER_NAME
)
@ConditionalOnMissingBean
(
value
=
IntegrationManagementConfigurer
.
class
,
name
=
IntegrationManagementConfigurer
.
MANAGEMENT_CONFIGURER_NAME
,
search
=
SearchStrategy
.
CURRENT
)
@ConditionalOnMissingBean
(
value
=
IntegrationManagementConfigurer
.
class
,
name
=
IntegrationManagementConfigurer
.
MANAGEMENT_CONFIGURER_NAME
,
search
=
SearchStrategy
.
CURRENT
)
public
IntegrationManagementConfigurer
managementConfigurer
()
{
IntegrationManagementConfigurer
configurer
=
new
IntegrationManagementConfigurer
();
configurer
.
setDefaultCountsEnabled
(
true
);
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/integration/SpringIntegrationMetricReader.java
View file @
b87e02dd
...
...
@@ -41,10 +41,10 @@ import org.springframework.lang.UsesJava7;
@UsesJava7
public
class
SpringIntegrationMetricReader
implements
MetricReader
{
private
final
IntegrationManagementConfigurer
managementC
onfigurer
;
private
final
IntegrationManagementConfigurer
c
onfigurer
;
public
SpringIntegrationMetricReader
(
IntegrationManagementConfigurer
managementC
onfigurer
)
{
this
.
managementConfigurer
=
managementC
onfigurer
;
public
SpringIntegrationMetricReader
(
IntegrationManagementConfigurer
c
onfigurer
)
{
this
.
configurer
=
c
onfigurer
;
}
@Override
...
...
@@ -54,60 +54,79 @@ public class SpringIntegrationMetricReader implements MetricReader {
@Override
public
Iterable
<
Metric
<?>>
findAll
()
{
List
<
Metric
<?>>
metrics
=
new
ArrayList
<
Metric
<?>>();
List
<
Metric
<?>>
result
=
new
ArrayList
<
Metric
<?>>();
String
[]
channelNames
=
this
.
configurer
.
getChannelNames
();
String
[]
handlerNames
=
this
.
configurer
.
getHandlerNames
();
String
[]
sourceNames
=
this
.
configurer
.
getSourceNames
();
addChannelMetrics
(
result
,
channelNames
);
addHandlerMetrics
(
result
,
handlerNames
);
addSourceMetrics
(
result
,
sourceNames
);
result
.
add
(
new
Metric
<
Integer
>(
"integration.handlerCount"
,
handlerNames
.
length
));
result
.
add
(
new
Metric
<
Integer
>(
"integration.channelCount"
,
channelNames
.
length
));
result
.
add
(
new
Metric
<
Integer
>(
"integration.sourceCount"
,
sourceNames
.
length
));
return
result
;
}
for
(
String
name
:
this
.
managementConfigurer
.
getChannelNames
())
{
MessageChannelMetrics
channelMetrics
=
this
.
managementConfigurer
.
getChannelMetrics
(
name
);
String
prefix
=
"integration.channel."
+
name
;
metrics
.
addAll
(
getStatistics
(
prefix
+
".errorRate"
,
channelMetrics
.
getErrorRate
()));
metrics
.
add
(
new
Metric
<
Long
>(
prefix
+
".sendCount"
,
channelMetrics
.
getSendCountLong
()));
metrics
.
addAll
(
getStatistics
(
prefix
+
".sendRate"
,
channelMetrics
.
getSendRate
()));
if
(
channelMetrics
instanceof
PollableChannelManagement
)
{
metrics
.
add
(
new
Metric
<
Long
>(
prefix
+
".receiveCount"
,
((
PollableChannelManagement
)
channelMetrics
).
getReceiveCountLong
()));
}
private
void
addChannelMetrics
(
List
<
Metric
<?>>
result
,
String
[]
names
)
{
for
(
String
name
:
names
)
{
addChannelMetrics
(
result
,
name
,
this
.
configurer
.
getChannelMetrics
(
name
));
}
}
for
(
String
name
:
this
.
managementConfigurer
.
getHandlerNames
())
{
MessageHandlerMetrics
handlerMetrics
=
this
.
managementConfigurer
.
getHandlerMetrics
(
name
);
String
prefix
=
"integration.handler."
+
name
;
metrics
.
addAll
(
getStatistics
(
prefix
+
".duration"
,
handlerMetrics
.
getDuration
()));
metrics
.
add
(
new
Metric
<
Long
>(
prefix
+
".activeCount"
,
handlerMetrics
.
getActiveCountLong
()));
private
void
addChannelMetrics
(
List
<
Metric
<?>>
result
,
String
name
,
MessageChannelMetrics
metrics
)
{
String
prefix
=
"integration.channel."
+
name
;
result
.
addAll
(
getStatistics
(
prefix
+
".errorRate"
,
metrics
.
getErrorRate
()));
result
.
add
(
new
Metric
<
Long
>(
prefix
+
".sendCount"
,
metrics
.
getSendCountLong
()));
result
.
addAll
(
getStatistics
(
prefix
+
".sendRate"
,
metrics
.
getSendRate
()));
if
(
metrics
instanceof
PollableChannelManagement
)
{
result
.
add
(
new
Metric
<
Long
>(
prefix
+
".receiveCount"
,
((
PollableChannelManagement
)
metrics
).
getReceiveCountLong
()));
}
}
for
(
String
name
:
this
.
managementConfigurer
.
getSourceNames
())
{
MessageSourceMetrics
sourceMetrics
=
this
.
managementConfigurer
.
getSourceMetrics
(
name
);
String
prefix
=
"integration.source."
+
name
;
metrics
.
add
(
new
Metric
<
Long
>(
prefix
+
".messageCount"
,
sourceMetrics
.
getMessageCountLong
()));
private
void
addHandlerMetrics
(
List
<
Metric
<?>>
result
,
String
[]
names
)
{
for
(
String
name
:
names
)
{
addHandlerMetrics
(
result
,
name
,
this
.
configurer
.
getHandlerMetrics
(
name
));
}
}
metrics
.
add
(
new
Metric
<
Integer
>(
"integration.handlerCount"
,
this
.
managementConfigurer
.
getHandlerNames
().
length
));
metrics
.
add
(
new
Metric
<
Integer
>(
"integration.channelCount"
,
this
.
managementConfigurer
.
getChannelNames
().
length
));
metrics
.
add
(
new
Metric
<
Integer
>(
"integration.sourceCount"
,
this
.
managementConfigurer
.
getSourceNames
().
length
));
private
void
addHandlerMetrics
(
List
<
Metric
<?>>
result
,
String
name
,
MessageHandlerMetrics
metrics
)
{
String
prefix
=
"integration.handler."
+
name
;
result
.
addAll
(
getStatistics
(
prefix
+
".duration"
,
metrics
.
getDuration
()));
long
activeCount
=
metrics
.
getActiveCountLong
();
result
.
add
(
new
Metric
<
Long
>(
prefix
+
".activeCount"
,
activeCount
));
}
return
metrics
;
private
void
addSourceMetrics
(
List
<
Metric
<?>>
result
,
String
[]
names
)
{
for
(
String
name
:
names
)
{
addSourceMetrics
(
result
,
name
,
this
.
configurer
.
getSourceMetrics
(
name
));
}
}
private
void
addSourceMetrics
(
List
<
Metric
<?>>
result
,
String
name
,
MessageSourceMetrics
sourceMetrics
)
{
String
prefix
=
"integration.source."
+
name
;
result
.
add
(
new
Metric
<
Long
>(
prefix
+
".messageCount"
,
sourceMetrics
.
getMessageCountLong
()));
}
private
Collection
<?
extends
Metric
<?>>
getStatistics
(
String
name
,
Statistics
statistic
)
{
private
Collection
<?
extends
Metric
<?>>
getStatistics
(
String
name
,
Statistics
stats
)
{
List
<
Metric
<?>>
metrics
=
new
ArrayList
<
Metric
<?>>();
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".mean"
,
statistic
.
getMean
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".max"
,
statistic
.
getMax
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".min"
,
statistic
.
getMin
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".stdev"
,
statistic
.
getStandardDeviation
()));
metrics
.
add
(
new
Metric
<
Long
>(
name
+
".count"
,
statistic
.
getCountLong
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".mean"
,
stats
.
getMean
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".max"
,
stats
.
getMax
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".min"
,
stats
.
getMin
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".stdev"
,
stats
.
getStandardDeviation
()));
metrics
.
add
(
new
Metric
<
Long
>(
name
+
".count"
,
stats
.
getCountLong
()));
return
metrics
;
}
@Override
public
long
count
()
{
int
totalChannelCount
=
this
.
managementC
onfigurer
.
getChannelNames
().
length
;
int
totalHandlerCount
=
this
.
managementC
onfigurer
.
getHandlerNames
().
length
;
int
totalSourceCount
=
this
.
managementC
onfigurer
.
getSourceNames
().
length
;
int
totalChannelCount
=
this
.
c
onfigurer
.
getChannelNames
().
length
;
int
totalHandlerCount
=
this
.
c
onfigurer
.
getHandlerNames
().
length
;
int
totalSourceCount
=
this
.
c
onfigurer
.
getSourceNames
().
length
;
return
totalChannelCount
+
totalHandlerCount
+
totalSourceCount
;
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java
View file @
b87e02dd
...
...
@@ -92,7 +92,7 @@ public class PublicMetricsAutoConfigurationTests {
public
void
metricReaderPublicMetrics
()
throws
Exception
{
load
();
assertThat
(
this
.
context
.
getBeansOfType
(
MetricReaderPublicMetrics
.
class
))
.
hasSize
(
1
);
.
hasSize
(
2
);
}
@Test
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/integration/SpringIntegrationMetricReaderNoJmxTests.java
View file @
b87e02dd
...
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
integration
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -53,7 +52,7 @@ public class SpringIntegrationMetricReaderNoJmxTests {
}
@Configuration
@Import
({
IntegrationAutoConfiguration
.
class
,
PublicMetricsAutoConfiguration
.
class
})
@Import
({
IntegrationAutoConfiguration
.
class
,
PublicMetricsAutoConfiguration
.
class
})
protected
static
class
TestConfiguration
{
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/integration/SpringIntegrationMetricReaderTests.java
View file @
b87e02dd
...
...
@@ -56,7 +56,8 @@ public class SpringIntegrationMetricReaderTests {
protected
static
class
TestConfiguration
{
@Bean
public
SpringIntegrationMetricReader
reader
(
IntegrationManagementConfigurer
managementConfigurer
)
{
public
SpringIntegrationMetricReader
reader
(
IntegrationManagementConfigurer
managementConfigurer
)
{
return
new
SpringIntegrationMetricReader
(
managementConfigurer
);
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java
View file @
b87e02dd
...
...
@@ -98,10 +98,9 @@ public class IntegrationAutoConfiguration {
}
@Configuration
@ConditionalOnClass
({
EnableIntegrationManagement
.
class
,
EnableIntegrationMBeanExport
.
class
})
@ConditionalOnMissingBean
(
value
=
IntegrationManagementConfigurer
.
class
,
name
=
IntegrationManagementConfigurer
.
MANAGEMENT_CONFIGURER_NAME
,
search
=
SearchStrategy
.
CURRENT
)
@ConditionalOnClass
({
EnableIntegrationManagement
.
class
,
EnableIntegrationMBeanExport
.
class
})
@ConditionalOnMissingBean
(
value
=
IntegrationManagementConfigurer
.
class
,
name
=
IntegrationManagementConfigurer
.
MANAGEMENT_CONFIGURER_NAME
,
search
=
SearchStrategy
.
CURRENT
)
@ConditionalOnProperty
(
prefix
=
"spring.jmx"
,
name
=
"enabled"
,
havingValue
=
"true"
,
matchIfMissing
=
true
)
protected
static
class
IntegrationManagementConfiguration
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java
View file @
b87e02dd
...
...
@@ -87,14 +87,17 @@ public class IntegrationAutoConfigurationTests {
MBeanServer
mBeanServer
=
this
.
context
.
getBean
(
MBeanServer
.
class
);
assertDomains
(
mBeanServer
,
true
,
"org.springframework.integration"
,
"org.springframework.integration.monitor"
);
assertThat
(
this
.
context
.
getBean
(
IntegrationManagementConfigurer
.
MANAGEMENT_CONFIGURER_NAME
)).
isNotNull
();
Object
bean
=
this
.
context
.
getBean
(
IntegrationManagementConfigurer
.
MANAGEMENT_CONFIGURER_NAME
);
assertThat
(
bean
).
isNotNull
();
}
@Test
public
void
disableJmxIntegration
()
{
load
(
"spring.jmx.enabled=false"
);
assertThat
(
this
.
context
.
getBeansOfType
(
MBeanServer
.
class
)).
hasSize
(
0
);
assertThat
(
this
.
context
.
getBeansOfType
(
IntegrationManagementConfigurer
.
class
)).
isEmpty
();
assertThat
(
this
.
context
.
getBeansOfType
(
IntegrationManagementConfigurer
.
class
))
.
isEmpty
();
}
@Test
...
...
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