aboutsummaryrefslogtreecommitdiff
path: root/kamon-statsd/src/main/scala/kamon/statsd/client/StatsdClient.scala
blob: 48940d0584b6cd146810917e316fc38e1f6178fd (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)
  }
}