Skip to content

Commit

Permalink
Merge pull request #34 from kenshoo/prefix-jvm-metrics
Browse files Browse the repository at this point in the history
standardize jvm metric names with dropwizard fixes #31
  • Loading branch information
liorhar committed Apr 22, 2015
2 parents 4cf897a + cd75da2 commit 94f1b89
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ created metrics, and to specify which HTTP Status codes should have individual m
2.3.0_0.1.8 - Support default registry in play java. Replace MetricsRegistry.default with MetricsRegistry.defaultRegistry (to support java where default is a reserved keyword)
2.3.0_0.1.9 - Add extra http codes, support configurable metrics names for requests filter
2.3.0_0.2.0 - Meter uncaught exceptions as 500 Internal Server Error
2.3.0_0.2.1 - Breaking Change! prefix jvm metric names to standardize with dropwizard


## License
This code is released under the Apache Public License 2.0.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ organization:= "com.kenshoo"

name := "metrics-play"

version := "2.3.0_0.2.0"
version := "2.3.0_0.2.1"

scalaVersion := "2.11.2"

Expand Down
9 changes: 5 additions & 4 deletions src/main/scala/com/kenshoo/play/metrics/MetricsPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ch.qos.logback.classic
import com.codahale.metrics.logback.InstrumentedAppender
import play.api.{Logger, Application, Play, Plugin}

import com.codahale.metrics.{MetricRegistry, SharedMetricRegistries}
import com.codahale.metrics.{JvmAttributeGaugeSet, MetricRegistry, SharedMetricRegistries}
import com.codahale.metrics.json.MetricsModule
import com.codahale.metrics.jvm.{ThreadStatesGaugeSet, GarbageCollectorMetricSet, MemoryUsageGaugeSet}

Expand Down Expand Up @@ -53,9 +53,10 @@ class MetricsPlugin(val app: Application) extends Plugin {
def setupJvmMetrics(registry: MetricRegistry) {
val jvmMetricsEnabled = app.configuration.getBoolean("metrics.jvm").getOrElse(true)
if (jvmMetricsEnabled) {
registry.registerAll(new GarbageCollectorMetricSet())
registry.registerAll(new MemoryUsageGaugeSet())
registry.registerAll(new ThreadStatesGaugeSet())
registry.register("jvm.attribute", new JvmAttributeGaugeSet())
registry.register("jvm.gc", new GarbageCollectorMetricSet())
registry.register("jvm.memory", new MemoryUsageGaugeSet())
registry.register("jvm.threads", new ThreadStatesGaugeSet())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MetricsPluginSpec extends Specification with Mockito with BeforeAfterExamp
val plugin = config()
plugin.onStart()
val metrics: Map[String, Metric] = SharedMetricRegistries.getOrCreate("default").getMetrics
metrics must haveKey("heap.usage")
metrics must haveKey("jvm.memory.heap.usage")
}

"registers logback metrics" in {
Expand Down

0 comments on commit 94f1b89

Please sign in to comment.