Skip to content

Commit 0d5c30f

Browse files
author
Dave Syer
committed
Add instance.uptime to VanillaPublicMetrics
1 parent 078e542 commit 0d5c30f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/VanillaPublicMetrics.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@
4040
public class VanillaPublicMetrics implements PublicMetrics {
4141

4242
private final MetricReader reader;
43+
private long timestamp;
4344

4445
public VanillaPublicMetrics(MetricReader reader) {
4546
Assert.notNull(reader, "MetricReader must not be null");
4647
this.reader = reader;
48+
this.timestamp = System.currentTimeMillis();
4749
}
4850

4951
@Override
@@ -75,6 +77,8 @@ protected void addMetrics(Collection<Metric<?>> result) {
7577
// Add JVM uptime in ms
7678
result.add(new Metric<Long>("uptime", new Long(ManagementFactory
7779
.getRuntimeMXBean().getUptime())));
80+
result.add(new Metric<Long>("instance.uptime", System.currentTimeMillis()
81+
- this.timestamp));
7882
}
7983

8084
/**

0 commit comments

Comments
 (0)