class StatsFilter[R <: Request] extends SimpleFilter[R, Response]
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
- Alphabetic
- By Inheritance
- StatsFilter
- SimpleFilter
- Filter
- Function2
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new StatsFilter(statsReceiver: StatsReceiver)
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.
- new StatsFilter(statsReceiver: StatsReceiver, responseClassifier: HttpResponseClassifier)
- 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
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def agnosticAndThen(next: TypeAgnostic): Filter[R, Response, R, Response]
- Definition Classes
- Filter
- def andThen(factory: ServiceFactory[R, Response]): ServiceFactory[R, Response]
- Definition Classes
- Filter
- def andThen(service: Service[R, Response]): Service[R, Response]
- Definition Classes
- Filter
- def andThen[Req2, Rep2](next: Filter[R, Response, Req2, Rep2]): Filter[R, Response, Req2, Rep2]
- Definition Classes
- Filter
- def andThenIf[Req2 >: R, Rep2 <: Response](condAndFilter: (Boolean, Filter[R, Response, Req2, Rep2])): Filter[R, Response, Req2, Rep2]
- Definition Classes
- Filter
- def andThenIf[Req2 >: R, Rep2 <: Response](conditional: Boolean, filter: Filter[R, Response, Req2, Rep2]): Filter[R, Response, Req2, Rep2]
- Definition Classes
- Filter
- def apply(request: R, service: Service[R, Response]): Future[Response]
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
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def curried: (R) => (Service[R, Response]) => Future[Response]
- Definition Classes
- Function2
- Annotations
- @unspecialized()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- Filter → Function2 → AnyRef → Any
- def tupled: ((R, Service[R, Response])) => Future[Response]
- Definition Classes
- Function2
- Annotations
- @unspecialized()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()