Class

com.twitter.finatra.http.filters

StatsFilter

Related Doc: package filters

Permalink

class StatsFilter[R <: Request] extends SimpleFilter[R, Response] with Logging

A drop-in replacement for com.twitter.finagle.http.filter.StatsFilter with per-route stats scoped under route/<name>/<method>.

Example stats for a successful GET request to a route named /foo:

route/foo/GET/failures 0
route/foo/GET/requests 1
route/foo/GET/status/200 1
route/foo/GET/status/2XX 1
route/foo/GET/success 1
route/foo/GET/time 857.000000 [857.0]
route/foo/GET/time/200 857.000000 [857.0]
route/foo/GET/time/2XX 857.000000 [857.0]
status/200 1
status/2XX 1
time/200 857.000000 [857.0]
time/2XX 857.000000 [857.0]

Example stats for a failed GET request to a route named /foo:

route/foo/GET/failures 1
route/foo/GET/ignored 0
route/foo/GET/requests 1
route/foo/GET/status/500 1
route/foo/GET/status/5XX 1
route/foo/GET/success 0
route/foo/GET/time 86.000000 [86.0]
route/foo/GET/time/500 86.000000 [86.0]
route/foo/GET/time/5XX 86.000000 [86.0]
status/500 1
status/5XX 1
time/500 86.000000 [86.0]
time/5XX 86.000000 [86.0]

Example stats for a failed GET request to a route named /foo which classifies the failure as Ignorable::

route/foo/GET/failures 0
route/foo/GET/ignored 1
route/foo/GET/requests 1
route/foo/GET/status/500 0
route/foo/GET/status/5XX 0
route/foo/GET/success 0
route/foo/GET/time 86.000000 [86.0]
route/foo/GET/time/500 86.000000 [86.0]
route/foo/GET/time/5XX 86.000000 [86.0]
status/500 0
status/5XX 0
time/500 86.000000 [86.0]
time/5XX 86.000000 [86.0]

requests == success + failures + ignored The logical success rate for a method can be calculated as success / (success + failures)

R

the type of the StatsFilter which is upper bounded by the com.twitter.finagle.http.Request type.

Annotations
@Singleton()
Note

It is expected that this Filter occurs "BEFORE" the ExceptionMappingFilter in a given filter chain, e.g., StatsFilter.andThen(ExceptionMappingFilter). It is expected that there SHOULD be a returned response because the ExceptionMappingFilter should return give a non-exception response.

See also

Finagle HTTP StatsFilter

Linear Supertypes
Logging, Logging, SimpleFilter[R, Response], Filter[R, Response, R, Response], (R, Service[R, Response]) ⇒ Future[Response], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. StatsFilter
  2. Logging
  3. Logging
  4. SimpleFilter
  5. Filter
  6. Function2
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new StatsFilter(statsReceiver: StatsReceiver)

    Permalink

    Secondary constructor which accepts a StatsReceiver.

    Secondary constructor which accepts a StatsReceiver. The HttpResponseClassifier is defaulted to HttpResponseClassifier.ServerErrorsAsFailures.

    statsReceiver

    the com.twitter.finagle.stats.StatsReceiver to which to record stats.

  2. new StatsFilter(statsReceiver: StatsReceiver, responseClassifier: HttpResponseClassifier)

    Permalink

    statsReceiver

    the com.twitter.finagle.stats.StatsReceiver to which to record stats.

    responseClassifier

    an HttpResponseClassifier used to determine when a response is successful or not.

    Annotations
    @Inject()

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def agnosticAndThen(next: TypeAgnostic): Filter[R, Response, R, Response]

    Permalink
    Definition Classes
    Filter
  5. def andThen(factory: ServiceFactory[R, Response]): ServiceFactory[R, Response]

    Permalink
    Definition Classes
    Filter
  6. def andThen(service: Service[R, Response]): Service[R, Response]

    Permalink
    Definition Classes
    Filter
  7. def andThen[Req2, Rep2](next: Filter[R, Response, Req2, Rep2]): Filter[R, Response, Req2, Rep2]

    Permalink
    Definition Classes
    Filter
  8. def andThenIf[Req2 >: R, Rep2 <: Response](condAndFilter: (Boolean, Filter[R, Response, Req2, Rep2])): Filter[R, Response, Req2, Rep2]

    Permalink
    Definition Classes
    Filter
  9. def andThenIf[Req2 >: R, Rep2 <: Response](conditional: Boolean, filter: Filter[R, Response, Req2, Rep2]): Filter[R, Response, Req2, Rep2]

    Permalink
    Definition Classes
    Filter
  10. def apply(request: R, service: Service[R, Response]): Future[Response]

    Permalink

    The application of the ResponseClassifier differs from the Finagle default.

    The application of the ResponseClassifier differs from the Finagle default. This class attempts to preserve information in the emitted metrics. That is, if an exception is returned, even if it is classified as a "success", we incr the exception counter(s) (in addition to the "success" or "failures" counters). Conversely, if a response (non-exception) is returned which is classified as a "failure", we incr the "failures" counter but we do not incr any exception counter. Finally, for responses or exceptions classified as "ignorable", we incr the "ignored" counter and the exception counter(s).

                     *-----------------*---------------------------*
                     |              Returned Response              |
    *----------------*-----------------*---------------------------*
    | Classification |    RESPONSE     |        EXCEPTION          |
    *----------------*-----------------*---------------------------*
    |  SUCCESSFUL    | success.incr()  | success.incr(), exc.incr()|
    *----------------*-----------------*---------------------------*
    |    FAILED      | failed.incr()   | failed.incr(), exc.incr() |
    *----------------|-----------------|---------------------------|
    |   IGNORABLE    | (no-op)         | ignored.incr(), exc.incr()|
    *----------------*-----------------*---------------------------*
    Definition Classes
    StatsFilter → Filter → Function2
    See also

    com.twitter.finagle.service.ResponseClassifier

    com.twitter.finagle.service.StatsFilter

  11. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  12. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def curried: (R) ⇒ (Service[R, Response]) ⇒ Future[Response]

    Permalink
    Definition Classes
    Function2
    Annotations
    @unspecialized()
  14. def debug(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  15. def debug(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  16. def debug(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  17. def debug(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  18. def debugFutureResult[T](msg: String)(func: ⇒ Future[T]): Future[T]

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  19. def debugResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  20. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  21. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  22. def error(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  23. def error(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  24. def error(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  25. def error(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  26. def errorResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  27. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  28. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  29. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  30. def info(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  31. def info(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  32. def info(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  33. def info(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  34. def infoResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  35. def isDebugEnabled(marker: Marker): Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  36. def isDebugEnabled: Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  37. def isErrorEnabled(marker: Marker): Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  38. def isErrorEnabled: Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  39. def isInfoEnabled(marker: Marker): Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  40. def isInfoEnabled: Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  41. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  42. def isTraceEnabled(marker: Marker): Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  43. def isTraceEnabled: Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  44. def isWarnEnabled(marker: Marker): Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  45. def isWarnEnabled: Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  46. final def logger: Logger

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  47. final def loggerName: String

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  48. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  49. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  50. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  51. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  52. def time[T](formatStr: String)(func: ⇒ T): T

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  53. def toString(): String

    Permalink
    Definition Classes
    Filter → Function2 → AnyRef → Any
  54. def trace(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  55. def trace(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  56. def trace(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  57. def trace(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  58. def traceResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  59. def tupled: ((R, Service[R, Response])) ⇒ Future[Response]

    Permalink
    Definition Classes
    Function2
    Annotations
    @unspecialized()
  60. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  61. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  62. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  63. def warn(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  64. def warn(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  65. def warn(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  66. def warn(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  67. def warnResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging

Inherited from Logging

Inherited from Logging

Inherited from SimpleFilter[R, Response]

Inherited from Filter[R, Response, R, Response]

Inherited from (R, Service[R, Response]) ⇒ Future[Response]

Inherited from AnyRef

Inherited from Any

Ungrouped