eigengo / monitor

Library for monitoring the Typesafe stack-based applications.
Apache License 2.0
127 stars 24 forks source link

output-metics module #80

Open janm399 opened 11 years ago

janm399 commented 11 years ago

Implement a module that exposes the CounterInterface for the http://metrics.codahale.com/.

vonnagy commented 11 years ago

I have a working module that supports this, but need to work out to major issues before making it an official "pull request".

The first hurdle is to potentially add the ability to create the monitoring actor within an existing actor system (see https://github.com/eigengo/monitor/issues/79 ).

The second is to plan out the default naming scheme for statistics that will be sent to the Codahale metrics registry. This format is most likely different then the statsd implementation that gets sent to DataDog. This should probably be a combination of the aspect and the actor path concatenated into some sort of dot notation.

For example:

Prefix: my-prefix
Aspect: akka.actor.delivered
ActorPath: akka://system/user/my-actor

my-prefix.my-actor.delivered

The above example is very simple, but the point is that I am looking for some recommendations for what the default input should be. The implementation I have been working on uses a naming marshaller that can be defined in the output.conf so the defaults could always be overwritten.

Example:

trait NameMarshaller {
  def prefix: String
  def buildName(aspect: String, tags: Seq[String]): String
}

class DefaultNameMarshaller(val prefix: String) extends NameMarshaller {

  require(prefix.isEmpty || prefix.endsWith("."), "Prefix must be empty or end with '.'")

  override def buildName(aspect: String, tags: Seq[String]): String = {
     // Put the default naming logic here
     ""
  }
}

The META-INF/monitor/output.conf would have something like the following:

org.eigengo.monitor.output.metrics {
    registry-class: "org.eigengo.monitor.output.metrics.DefaultRegistryProvider"
    naming-class: "org.eigengo.monitor.output.metrics.DefaultNameMarshaller"
    prefix: ""
    refresh: 5
}