scalableminds / play-airbrake   0.5.0

MIT License GitHub

Submit your play exceptions to airbrake

Scala versions: 2.11

Airbrake.io notifier for Play 2.4

Automatically inform airbrake about failing requests and exceptions in your play application. This module was originally forked from https://github.com/teamon/play-airbrake

The original author is Tymon Tobolski. Since the original repository is not maintained any more this module gets published using a different organization.

Instalation

Add play-airbrake to your build.sbt or project/Build.scala file

libraryDependencies += "com.scalableminds" %% "play-airbrake" % "0.5.0"

Your app/Global.scala should look like this

import play.api._
import play.api.mvc._
import play.airbrake.Airbrake

object Global extends GlobalSettings {

  override def onError(request: RequestHeader, ex: Throwable) = {
    Airbrake.notify(request, ex)
    super.onError(request, ex)
  }

}

For javascript notifications (not free plan)

<head>
  @Html(play.airbrake.Airbrake.js)
</head>

For java integration your app/Global.java should look like this

class Global extends GlobalSettings {
  @Override
  public Result onError(RequestHeader request, Throwable t) {
    Airbrake.notify(request, t);
    return super.onError(request, t);
  }
}

Configuration

Key Description
airbrake.apiKey String, required airbrake project api key
airbrake.ssl Boolean, optional, defaults to false set to true if you have airbrake plan with SSL support
airbrake.enabled Boolean, optional, defaults to Play.isProd optionally enable/disable notifications for different environment
airbrake.endpoint String, optional, defaults to api.airbrake.io/notifier_api/v2/notices point notifier to you custom airbrake compatible service (e.g. errbit)
airbrake.environment String, optional, defaults to Play.current.mode defines the environment the application is executed in, e.g. Prod
airbrake.appVersion String, optional, defaults to configuration value application.version or to 0.1 if none of the before mentioned is present defines the current version of the application