This play module provides some support for @codahale Metrics library in a Play2 application (Scala). It allows you to get insights about the state of your application, for example how response times behave, with which HTTP codes your service responds, how many log entries are written.
The name stems from the german mining term Markscheider, which was a land surveyor who was responsible for mapping of the mine.
Add metrics-play dependency in your
libraryDependencies += Seq( "org.zalando" %% "markscheider" % "2.5.2" )
To enable the plugin, add to
play.modules.enabled += "org.zalando.markscheider.PlayMetricsModule"
Then add a class
Filters as described in The Play docs to
include the filter in your filter chain.
import javax.inject.Inject import play.api.http.DefaultHttpFilters import org.zalando.markscheider.MetricsFilter class Filters @Inject() ( metricsFilter: MetricsFilter ) extends DefaultHttpFilters(metricsFilter)
You may want to have an endpoint that delivers the metrics, which you can add via
GET /metrics org.zalando.markscheider.MetricsController.metrics
The metrics are created in a way that is compatible with ZMON.
After that, you can get metrics information in your service at
/metrics. By default, that endpoint is unsecured (no authentication in place).
For an example output of the endpoint, see
The basic configuration is supported through the default configuration file, see
conf/reference.conf. You can override
the settings in your
application.conf. Otherwise the default settings are used.
Note: the namespace for the configuration is
We welcome contributions. See CONTRIBUTIONS.md for details.
This lib was adapted from https://github.com/fr3akX/metrics-play, which contains code from other sources as well.
This code is released under the Apache Public License 2.0.