diff options
3 files changed, 70 insertions, 0 deletions
diff --git a/kamon-statsd/src/main/resources/reference.conf b/kamon-statsd/src/main/resources/reference.conf new file mode 100644 index 00000000..9d09a709 --- /dev/null +++ b/kamon-statsd/src/main/resources/reference.conf @@ -0,0 +1,12 @@ +# ==================================== # +# Kamon-Statsd Reference Configuration # +# ==================================== # + +kamon { + statsd { + prefix = kamon-app + hostname = statsd.example.com + port = 8125 + } + } +}
\ No newline at end of file diff --git a/kamon-statsd/src/main/scala/kamon/statsd/Statsd.scala b/kamon-statsd/src/main/scala/kamon/statsd/Statsd.scala new file mode 100644 index 00000000..d4198c7f --- /dev/null +++ b/kamon-statsd/src/main/scala/kamon/statsd/Statsd.scala @@ -0,0 +1,36 @@ +/* + * ========================================================================================= + * Copyright © 2013-2014 the kamon project <http://kamon.io/> + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +package kamon.statsd + +import akka.actor.{ ExtendedActorSystem, Extension, ExtensionIdProvider, ExtensionId } +import kamon.Kamon + +object Statsd extends ExtensionId[StatsdExtension] with ExtensionIdProvider { + override def lookup(): ExtensionId[_ <: Extension] = Statsd + override def createExtension(system: ExtendedActorSystem): StatsdExtension = new StatsdExtension(system) +} + +class StatsdExtension(private val system: ExtendedActorSystem) extends Kamon.Extension { + publishInfoMessage(system, "Statsd Extension Loaded!!") + + private val config = system.settings.config.getConfig("kamon.statsd") + + val prefix = config.getString("prefix") + val hostname = config.getString("hostname") + val port = config.getInt("port") +} + diff --git a/kamon-statsd/src/main/scala/kamon/statsd/client/StatsdClient.scala b/kamon-statsd/src/main/scala/kamon/statsd/client/StatsdClient.scala new file mode 100644 index 00000000..48940d05 --- /dev/null +++ b/kamon-statsd/src/main/scala/kamon/statsd/client/StatsdClient.scala @@ -0,0 +1,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) + } +}
\ No newline at end of file |