Permalink
Browse files

fixed bug: memory usage stats wasn't updating

  • Loading branch information...
1 parent 95e3dd6 commit 71904c01004c6031b5c3d1ee6db8e330cfd5cb09 @sluu sluu committed Apr 2, 2013
Showing with 16 additions and 10 deletions.
  1. +15 −9 management/src/main/scala/com/gu/management/JvmMetrics.scala
  2. +1 −1 version.sbt
@@ -67,15 +67,21 @@ object JvmMetrics {
lazy val memoryUsage =
try {
ManagementFactory.getMemoryPoolMXBeans().toList flatMap { memPool: MemoryPoolMXBean =>
- val memoryUsage = memPool.getUsage
- if (memoryUsage == null) None
- else Some(new GaugeMetric(
- group = "jvm",
- name = "%s memory usage".format(memPool.getName),
- title = "%s Memory Usage".format(memPool.getName),
- description = "%s memory usage as percentage of max value".format(memPool.getName),
- getValue = () => math.round(memoryUsage.getUsed.toFloat / memoryUsage.getMax * 100)
- ))
+ {
+ Option(memPool.getUsage) match {
+ case Some(_) => Some(new GaugeMetric(
+ group = "jvm",
+ name = "%s memory usage".format(memPool.getName),
+ title = "%s Memory Usage".format(memPool.getName),
+ description = "%s memory usage as percentage of max value".format(memPool.getName),
+ getValue = () => {
+ val currentUsage = memPool.getUsage
+ math.round(currentUsage.getUsed.toFloat / currentUsage.getMax * 100)
+ }
+ ))
+ case None => None
+ }
+ }
}
} catch {
case e: Exception =>
View
@@ -1,2 +1,2 @@
-version in ThisBuild := "5.28"
+version in ThisBuild := "5.29"

0 comments on commit 71904c0

Please sign in to comment.