<commit_before>package se.chimps.bitziness.core.services.metrics.adapters

import com.aphyr.riemann.client.{RiemannClient, RiemannBatchClient, IRiemannClient}
import se.chimps.bitziness.core.services.metrics.MetricService

class RiemannAdapter(val settings:RiemannSettings, override val host:String) extends MetricService {

  var client:IRiemannClient = _

  override def metric(host: String, service: String, name: String, metric: Long, state: Option[String], metadata: Map[String, String]): Unit = {
    val event = client.event()
      .host(host)
      .service(s"$service.$name")
      .metric(metric)

    state.foreach(event.state)
    metadata.foreach(map => event.attribute(map._1, map._2))

    client.sendEvent(event.build())
  }

  override def metric(host: String, service: String, name: String, metric: BigDecimal, state: Option[String], metadata: Map[String, String]): Unit = {
    val event = client.event()
      .host(host)
      .service(s"$service.$name")
      .metric(metric.floatValue())

    state.foreach(event.state)
    metadata.foreach(map => event.attribute(map._1, map._2))

    client.sendEvent(event.build())
  }

  override def metric(host: String, service: String, name: String, metric: Boolean, state: Option[String], metadata: Map[String, String]): Unit = {
    val value = metric match {
      case true => 1
      case _ => 0
    }

    val event = client.event()
      .host(host)
      .service(s"$service.$name")
      .metric(value)

    state.foreach(event.state)
    metadata.foreach(map => event.attribute(map._1, map._2))

    client.sendEvent(event.build())
  }

  override def metric(host: String, service: String, name: String, metric: String, state: Option[String], metadata: Map[String, String]): Unit = {
    val value = BigDecimal(metric)

    val event = client.event()
      .host(host)
      .service(s"$service.$name")
      .metric(value.floatValue())

    state.foreach(event.state)
    metadata.foreach(map => event.attribute(map._1, map._2))

    client.sendEvent(event.build())
  }

  override def initialize(): Unit = {
    super.initialize()
    client = new RiemannBatchClient(RiemannClient.tcp(settings.host, settings.port))
  }
}

case class RiemannSettings(host:String, port:Int, buffer:Int)<commit_msg>Forgott the buffer.<commit_after>package se.chimps.bitziness.core.services.metrics.adapters

import com.aphyr.riemann.client.{RiemannClient, RiemannBatchClient, IRiemannClient}
import se.chimps.bitziness.core.services.metrics.MetricService

class RiemannAdapter(val settings:RiemannSettings, override val host:String) extends MetricService {

  var client:IRiemannClient = _

  override def metric(host: String, service: String, name: String, metric: Long, state: Option[String], metadata: Map[String, String]): Unit = {
    val event = client.event()
      .host(host)
      .service(s"$service.$name")
      .metric(metric)

    state.foreach(event.state)
    metadata.foreach(map => event.attribute(map._1, map._2))

    client.sendEvent(event.build())
  }

  override def metric(host: String, service: String, name: String, metric: BigDecimal, state: Option[String], metadata: Map[String, String]): Unit = {
    val event = client.event()
      .host(host)
      .service(s"$service.$name")
      .metric(metric.floatValue())

    state.foreach(event.state)
    metadata.foreach(map => event.attribute(map._1, map._2))

    client.sendEvent(event.build())
  }

  override def metric(host: String, service: String, name: String, metric: Boolean, state: Option[String], metadata: Map[String, String]): Unit = {
    val value = metric match {
      case true => 1
      case _ => 0
    }

    val event = client.event()
      .host(host)
      .service(s"$service.$name")
      .metric(value)

    state.foreach(event.state)
    metadata.foreach(map => event.attribute(map._1, map._2))

    client.sendEvent(event.build())
  }

  override def metric(host: String, service: String, name: String, metric: String, state: Option[String], metadata: Map[String, String]): Unit = {
    val value = BigDecimal(metric)

    val event = client.event()
      .host(host)
      .service(s"$service.$name")
      .metric(value.floatValue())

    state.foreach(event.state)
    metadata.foreach(map => event.attribute(map._1, map._2))

    client.sendEvent(event.build())
  }

  override def initialize(): Unit = {
    super.initialize()
    client = new RiemannBatchClient(RiemannClient.tcp(settings.host, settings.port), settings.buffer)
  }
}

case class RiemannSettings(host:String, port:Int, buffer:Int)
{'fraction_non_alphanumeric': 0.1394788701554631, 'fraction_numerical': 0.004379242391066345, 'mean_word_length': 3.8389830508474576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3407290', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1366, 'n_words': 306}