Packages

package filters

Type Members

  1. class AccessLoggingFilter[R <: Request] extends SimpleFilter[R, Response]

    Provides a standard "Access Log" -- a list of all requests through this Filter.

    Provides a standard "Access Log" -- a list of all requests through this Filter. Typically, this Filter is provided by the com.twitter.finatra.http.modules.AccessLogModule which provides an implementation for the com.twitter.finagle.filter.LogFormatter param as an instance of com.twitter.finagle.http.filter.CommonLogFormatter.

    Usage

    To use, configure a logger (with your preferred logging implementation) over this class which writes to a specific file (typically named, access.log).

    R

    - "Request" type param which must be a subtype of com.twitter.finagle.http.Request.

    Annotations
    @Singleton()
    Note

    This Filter should occur as early in the Filter chain as possible such that it is "above" the com.twitter.finatra.http.filters.ExceptionMappingFilter as it is expected that servicing requests with this Filter will always return a com.twitter.finagle.http.Response.

    ,

    This Filter is included in the Finatra com.twitter.finatra.http.filters.CommonFilters.

    See also

    Common Log Format

    com.twitter.finatra.http.filters.CommonFilters

    com.twitter.finatra.http.filters.ExceptionMappingFilter

    com.twitter.finatra.http.modules.AccessLogModule

    com.twitter.finagle.filter.LogFormatter

    com.twitter.finagle.http.filter.CommonLogFormatter

  2. class CommonFilters extends MergedFilter[Request, Response]

    A typical collection of Filters for HTTP services.

    A typical collection of Filters for HTTP services. Ordering of Filters is important. This is meant to be a convenience utility and does not serve all cases. It is primarily meant to be illustrative of a recommended order of organization for the given filters which can be chained together manually but which are collected here for the many cases where you only need the functionality implemented here.

    Annotations
    @Singleton()
    Note

    Filter ordering is determined by the implementation of MergedFilter and can be read as Requests enter the top Filter and progress down, Responses traverse in the opposite manner from the bottom up.

    ,

    HttpNackFilter converts Finagle's nacks into HttpNackExceptions. This Filter MUST come "below" the ExceptionMappingFilter otherwise the HttpNackExceptions will not be properly converted into a meaningful HTTP response.

  3. class ExceptionMappingFilter[R <: Request] extends SimpleFilter[R, Response]

    Filter which converts exceptions into HTTP responses.

    Filter which converts exceptions into HTTP responses. NOTE: Should be as close to the start of the filter chain as possible.

    Annotations
    @Singleton()
  4. class HttpNackFilter[R <: Request] extends SimpleFilter[R, Response]

    This Filter converts Finagle nacks into HttpNackExceptions to be handled by a registered ExceptionMapper[HttpNackException].

    This Filter converts Finagle nacks into HttpNackExceptions to be handled by a registered ExceptionMapper[HttpNackException]. A "nack" is a Negative ACKnowledgement. Responding with a nack is one way a service may exert back pressure.

    Annotations
    @Singleton()
    See also

    com.twitter.finatra.http.internal.exceptions.HttpNackExceptionMapper

    Finagle HttpNackFilter

    Finagle NACK

  5. class HttpResponseFilter[R <: Request] extends SimpleFilter[R, Response]

    HttpResponseFilter does the following:

    HttpResponseFilter does the following:

    • Sets the 'Server' and 'Date' response header values.
    • Optionally turns a relative 'Location' header value into a full URL. See fullyQualifyLocationHeader.

    By default this filter allows for returning relative references as 'Location' header values. In order to always attempt to fully specify a relative reference, this class should be instantiated with the constructor arg fullyQualifyLocationHeader set to 'true'.

    Annotations
    @Singleton()
    Note

    This filter does NOT throw exceptions when it is unable to set a location header value because of non RFC 7230 compliant values. Generally this filter is installed "above" the ExceptionMappingFilter and therefore translation of an exception into an appropriate HTTP response is not available thus the filter logs a warning message. This means that if there is a non-compliant 'Location' header value in the outgoing Response this filter will not fully qualify, nor replace, nor remove it.

    See also

    HTTP location

    Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content

    Relative Reference

  6. class LoggingMDCFilter[Req, Rep] extends SimpleFilter[Req, Rep]
    Annotations
    @Singleton()
  7. 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>.

    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

  8. class TraceIdMDCFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    Filter to log tracing data into MDC bag of attributes.

    Filter to log tracing data into MDC bag of attributes. Includes traceSampled flag that indicates if the trace is available via tracers Note: Any MDC filter must be used in conjunction with the LoggingMDCFilter to ensure that diagnostic context is properly managed.

    Annotations
    @Singleton()

Ungrouped