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
8b97c3b3
Commit
8b97c3b3
authored
Dec 09, 2015
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add nonheap metrics to /metrics endpoint
Fixes gh-4712
parent
2d003a69
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
SystemPublicMetrics.java
...gframework/boot/actuate/endpoint/SystemPublicMetrics.java
+22
-0
SystemPublicMetricsTests.java
...ework/boot/actuate/endpoint/SystemPublicMetricsTests.java
+5
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/SystemPublicMetrics.java
View file @
8b97c3b3
...
...
@@ -78,6 +78,7 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
* Add metrics from ManagementFactory if possible. Note that ManagementFactory is not
* available on Google App Engine.
* @param result the result
* @param mem
*/
private
void
addManagementMetrics
(
Collection
<
Metric
<?>>
result
)
{
try
{
...
...
@@ -107,6 +108,27 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
result
.
add
(
new
Metric
<
Long
>(
"heap.init"
,
memoryUsage
.
getInit
()
/
1024
));
result
.
add
(
new
Metric
<
Long
>(
"heap.used"
,
memoryUsage
.
getUsed
()
/
1024
));
result
.
add
(
new
Metric
<
Long
>(
"heap"
,
memoryUsage
.
getMax
()
/
1024
));
memoryUsage
=
ManagementFactory
.
getMemoryMXBean
().
getNonHeapMemoryUsage
();
result
.
add
(
new
Metric
<
Long
>(
"nonheap.committed"
,
memoryUsage
.
getCommitted
()
/
1024
));
result
.
add
(
new
Metric
<
Long
>(
"nonheap.init"
,
memoryUsage
.
getInit
()
/
1024
));
result
.
add
(
new
Metric
<
Long
>(
"nonheap.used"
,
memoryUsage
.
getUsed
()
/
1024
));
result
.
add
(
new
Metric
<
Long
>(
"nonheap"
,
memoryUsage
.
getMax
()
/
1024
));
Metric
<
Long
>
mem
=
findMemory
(
result
);
if
(
mem
!=
null
)
{
mem
.
increment
(
new
Long
(
memoryUsage
.
getUsed
()
/
1024
).
intValue
());
}
}
private
Metric
<
Long
>
findMemory
(
Collection
<
Metric
<?>>
result
)
{
for
(
Metric
<?>
metric
:
result
)
{
if
(
"mem"
.
equals
(
metric
.
getName
()))
{
@SuppressWarnings
(
"unchecked"
)
Metric
<
Long
>
value
=
(
Metric
<
Long
>)
metric
;
return
value
;
}
}
return
null
;
}
/**
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/SystemPublicMetricsTests.java
View file @
8b97c3b3
...
...
@@ -50,6 +50,11 @@ public class SystemPublicMetricsTests {
assertTrue
(
results
.
containsKey
(
"heap.used"
));
assertTrue
(
results
.
containsKey
(
"heap"
));
assertTrue
(
results
.
containsKey
(
"nonheap.committed"
));
assertTrue
(
results
.
containsKey
(
"nonheap.init"
));
assertTrue
(
results
.
containsKey
(
"nonheap.used"
));
assertTrue
(
results
.
containsKey
(
"nonheap"
));
assertTrue
(
results
.
containsKey
(
"threads.peak"
));
assertTrue
(
results
.
containsKey
(
"threads.daemon"
));
assertTrue
(
results
.
containsKey
(
"threads.totalStarted"
));
...
...
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