aboutsummaryrefslogtreecommitdiff
path: root/kamon-statsd/src/main/scala/kamon/statsd/client/StatsdClient.scala
blob: 233765584afb3b707139d7d7709b1277d4b2dc1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package kamon.statsd.client

import akka.actor.{ActorRef, Actor}
import akka.io.{Udp, IO}
import java.net.InetSocketAddress
import akka.util.ByteString

class StatsdClient(remote: InetSocketAddress) extends Actor {
  import context.system

  IO(Udp) ! Udp.SimpleSender

  def receive = {
    case Udp.SimpleSenderReady =>
      context.become(ready(sender()))
  }

  def ready(send: ActorRef): Receive = {
    case msg: String =>
      send ! Udp.Send(ByteString(msg), remote)
  }
}