microservice-bootstrap-java

Build Status Download

This library implements a basic Play Global object and related functionality for frontend applications.

Creating a Global object for your microservice application

Simply create an object extending DefaultMicroserviceGlobal. That will provide you with the common filters and error handling. You can also override microserviceFilters attribute if you need to alter the default set of filters.

Metrics plugin

To enable the Metrics plugin in your application, add this line to your play.plugins file:

1:com.kenshoo.play.metrics.MetricsPlugin

and a block similar to this in your Play application config file:

metrics {
    name = ${appName}
    rateUnit = SECONDS
    durationUnit = SECONDS
    showSamples = true
    jvm = true
    enabled = true
}

You can also enable the plugin's admin servlet by adding this line to your routes file:

GET     /admin/metrics          com.kenshoo.play.metrics.MetricsController.metrics

and configure the controller in your application conf file:

controllers {
    com.kenshoo.play.metrics.MetricsController {
        needsAuth = false
        needsLogging = false
        needsAuditing = false
    }
}

Publishing metrics to Graphite

To enable Graphite publisher in your application, add a block like this to your application conf file:

microservice {
    metrics {
        graphite {
            host = graphite
            port = 2003
            prefix = play.${appName}.
            enabled = true
        }
    }

and point your Global object (inherited from DefaultMicroserviceGlobal ) to it

override def microserviceMetricsConfig(implicit app: Application): Option[Configuration] = app.configuration.getConfig("microservice.metrics")

Installing

Add the following to your SBT build:

resolvers += Resolver.bintrayRepo("hmrc", "releases")

libraryDependencies += "uk.gov.hmrc" %% "microservice-bootstrap-java" % "[INSERT-VERSION]"

License

This code is open source software licensed under the Apache 2.0 License.