Version Matrix


Build Status Download

play-auditing contains code to facilitate creation of audit events and their publication to datastream. This includes both explicit audit events, and implicit audit events via http-verbs.

Adding to your build

In your SBT build add:

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

libraryDependencies += "" %% "play-auditing" % "x.x.x"


Implicit auditing in conjunction with http-verbs

import{AppName, RunMode}

object Audit extends AuditConnector with RunMode {
  override lazy val auditingConfig = LoadAuditingConfig(s"$env.auditing")

protected object WSHttp extends WSGet with WSPut with WSPost with WSDelete with WSPatch with AppName with RunMode with HttpAuditing {
  override val hooks = Seq(AuditingHook)
  override val auditConnector = Audit

For more information on http-verbs, please see the docs here

Explicit auditing

import{Audit, DataEvent, EventTypes}

val appName = "preferences"
val audit = Audit(appName,
  new AuditConnector with RunMode {
    override lazy val auditingConfig = LoadAuditingConfig(s"$env.auditing")})

def sendDataEvent(
 transactionName: String, path: String = "N/A", tags: Map[String, String] = Map.empty, detail: Map[String, String])
   (implicit hc: HeaderCarrier): Unit = {

  audit.sendDataEvent(DataEvent(appName, EventTypes.Succeeded,
    tags = hc.toAuditTags(transactionName, path) ++ tags,
    detail = hc.toAuditDetails(detail.toSeq: _*)))



You'll also need to supply an auditing configuration.

Request auditing is provided for all HTTP requests that are made using http-verbs that use the AuditingHook. Each request/response pair results in an audit message being created and sent to an external auditing service for processing. To configure this service, your Play configuration file needs to include:

auditing {
  enabled = true
  traceRequests = true
  consumer {
    baseUri {
      host = ...
      port = ...

HttpAuditing provides def auditDisabledForPattern = ("""http://.*\.service""").r which client applications may chose to override when mixing in HttpAuditing.

NOTE: This configuration used to be provided by reading Play configuration property <env>.http-client.audit.disabled-for which is now obsolete.


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