Created
January 13, 2015 21:55
-
-
Save jamescway/1354f6e621973b700e4c to your computer and use it in GitHub Desktop.
Finagle Statsd receiver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://groups.google.com/forum/#!topic/finaglers/0g2ySTVtZsg | |
import com.twitter.finagle.stats.{Counter, Gauge, Stat, StatsReceiver} | |
/** | |
* Created by mmlac on 8/13/14. | |
*/ | |
class StatsDStatsReceiver extends StatsReceiver { | |
override val repr: AnyRef = this | |
override def counter(name: String*): Counter = StatsDCounter(name.foldLeft("")( (b, next) => b +"."+ next)) | |
override def addGauge(name: String*)(f: => Float): Gauge = StatsDGauge("") | |
override def stat(name: String*): Stat = StatsDStat(name.foldLeft("")( (b, next) => b +"."+ next)) | |
} | |
case class StatsDCounter(name : String) extends Counter { | |
override def incr(delta: Int): Unit = println(s"increeeemeeeeeeent $name!!!!!") | |
} | |
case class StatsDGauge(name: String) extends Gauge { | |
override def remove(): Unit = Unit | |
} | |
case class StatsDStat(name: String) extends Stat { | |
override def add(value: Float): Unit = println(s"add. this. stat! $name") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment