Build Status Coverage Status Apache licensed

Markscheider

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.

Getting started

Add metrics-play dependency in your build.sbt:

libraryDependencies += Seq(
  "org.zalando" %% "markscheider" % "2.5.2"
)

To enable the plugin, add to conf/application.conf:

 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

in your routes file.

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 example-output.json.

Configuration

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 org.zalando.markscheider.

Contributions

We welcome contributions. See CONTRIBUTIONS.md for details.

Credits

This lib was adapted from https://github.com/fr3akX/metrics-play, which contains code from other sources as well.

License

This code is released under the Apache Public License 2.0.