<commit_before>package com.twitter.finagle.stats

import com.twitter.common.stats.Stats
import com.twitter.common.stats.{StatImpl => JStat}
import com.twitter.common.base.Supplier

class CommonsStatsReceiver extends StatsReceiverWithCumulativeGauges {
  protected[this] def registerGauge(name: Seq[String], f: => Float) {
    Stats.STATS_PROVIDER.makeGauge(variableName(name), new Supplier[java.lang.Float]{
      def get = {f.asInstanceOf[java.lang.Float]}
    })
  }

  protected[this] def deregisterGauge(name: Seq[String]) {
    // not implmented in commons
  }

  def counter(name: String*) = new Counter {
    private[this] val name_ = variableName(name)

    def incr(delta: Int) { Stats.STATS_PROVIDER.makeCounter(name_).getAndAdd(delta) }
  }

  def stat(name: String*) = new Stat {
    private[this] val name_ = variableName(name)
    private[this] val float = 0.0f

    private[this] val jstat = new JStat[Float](name_){
      def read: Float = float
    }

    def add(value: Float) {
    }
  }

  private[this] def variableName(name: Seq[String]) = name mkString "_"
}<commit_msg>[split] actually increment the stat<commit_after>package com.twitter.finagle.stats

import com.twitter.common.stats.Stats
import com.twitter.common.stats.{StatImpl => JStat}
import com.twitter.common.base.Supplier

class CommonsStatsReceiver extends StatsReceiverWithCumulativeGauges {
  protected[this] def registerGauge(name: Seq[String], f: => Float) {
    Stats.STATS_PROVIDER.makeGauge(variableName(name), new Supplier[java.lang.Float]{
      def get = {f.asInstanceOf[java.lang.Float]}
    })
  }

  protected[this] def deregisterGauge(name: Seq[String]) {
    // not implmented in commons
  }

  def counter(name: String*) = new Counter {
    private[this] val name_ = variableName(name)

    def incr(delta: Int) { Stats.STATS_PROVIDER.makeCounter(name_).getAndAdd(delta) }
  }

  def stat(name: String*) = new Stat {
    private[this] val name_ = variableName(name)
    private[this] val float = 0.0f

    private[this] val jstat = new JStat[Float](name_){
      def read: Float = float
    }

    def add(value: Float) {
      float += value
    }
  }

  private[this] def variableName(name: Seq[String]) = name mkString "_"
}
{'fraction_non_alphanumeric': 0.12292507851054285, 'fraction_numerical': 0.001794526693584567, 'mean_word_length': 4.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7155144', 'n_tokens_mistral': 762, 'n_tokens_neox': 731, 'n_words': 160}