All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.finagle.thrift.ThriftMethodStats.scala Maven / Gradle / Ivy

There is a newer version: 24.2.0
Show newest version
package com.twitter.finagle.thrift

import com.twitter.finagle.stats.{Counter, LazyStatsReceiver, NullStatsReceiver, StatsReceiver}

object ThriftMethodStats {

  def apply(stats: StatsReceiver): ThriftMethodStats = {
    val wrapped = new LazyStatsReceiver(stats)
    ThriftMethodStats(
      wrapped.counter("requests"),
      wrapped.counter("success"),
      wrapped.counter("failures"),
      wrapped.scope("failures")
    )
  }

  private[this] val NullThriftMethodStats = apply(NullStatsReceiver)

  /**
   * An instance of [[ThriftMethodStats]] that is backed by a
   * `NullStatsReceiver`.
   *
   * This can be used as a sentinel instance where everything is a no-op.
   */
  def Null: ThriftMethodStats = NullThriftMethodStats
}

case class ThriftMethodStats private (
  requestsCounter: Counter,
  successCounter: Counter,
  failuresCounter: Counter,
  failuresScope: StatsReceiver)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy