Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A StatsDClient helper function for doing custom DataDog metrics in scala
package com.kukaatx.utilities
import javax.inject.Singleton
import com.timgroup.statsd._
import play.api.{Configuration, Environment}
trait StatsDBinding {
val configuration: Configuration
val environment: Environment
def getStatsDClient: StatsDClient = {
try {
val stub = configuration.getBoolean(s"statsd.stub.${environment.mode.toString.toLowerCase}").contains(true)
if (stub) {
new NoOpStatsDClient()
} else {
new NonBlockingStatsDClient(
} catch {
case e: Throwable =>
println(s"Exception when creating statsd client. Disabling statsd logging. e=$e")
new NoOpStatsDClient()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment