Class RESTEasyTracing


  • public abstract class RESTEasyTracing
    extends Object
    • Field Detail

      • PROPERTY_NAME

        public static final String PROPERTY_NAME
        TracingLogger instance is placed in request context properties under this name.
      • HEADER_THRESHOLD

        public static final String HEADER_THRESHOLD
        Request header name to change application default tracing level.
        See Also:
        Constant Field Values
      • HEADER_ACCEPT

        public static final String HEADER_ACCEPT
        Request header name to switch on request tracing. Make sense in case of tracing support enabled by ON_DEMAND value.
        See Also:
        Constant Field Values
      • HEADER_ACCEPT_FORMAT

        public static final String HEADER_ACCEPT_FORMAT
        Request header name to indicate the tracing info format. Currently we support `TEXT` format and `JSON` format.
        See Also:
        Constant Field Values
      • HEADER_LOGGER

        public static final String HEADER_LOGGER
        Request header name to set JDK logger name suffix to identify a request logs.
        See Also:
        Constant Field Values
      • HEADER_RESPONSE_FORMAT

        protected static final String HEADER_RESPONSE_FORMAT
        Response header name format.
        See Also:
        Constant Field Values
      • TRACING_LOGGER_NAME_PREFIX

        protected static final String TRACING_LOGGER_NAME_PREFIX
        JDK logger name prefix.
        See Also:
        Constant Field Values
    • Constructor Detail

      • RESTEasyTracing

        public RESTEasyTracing()
    • Method Detail

      • isLogEnabled

        public abstract boolean isLogEnabled​(RESTEasyTracingEvent event)
        Test if a tracing support is enabled if event can be logged (according to event.level and threshold level set).
        Parameters:
        event - event type to be tested
        Returns:
        true if event can be logged
      • logDuration

        public abstract void logDuration​(RESTEasyTracingEvent event,
                                         long fromTimestamp,
                                         Object... args)
        Try to log event according to event level and request context threshold level setting.

        If logging support is switched on for current request and event setting the method computes duration of event and log message. If fromTimestamp is not set (i.e. -1) then duration of event is 0.

        Parameters:
        event - event type to be logged
        fromTimestamp - logged event is running from the timestamp in nanos. -1 in case event has no duration
        args - message arguments (in relation to RESTEasyTracingEvent.messageFormat()
      • timestamp

        public abstract long timestamp​(RESTEasyTracingEvent event)
        If logging support is switched on for current request and event setting the method returns current timestamp in nanos.
        Parameters:
        event - event type to be logged
        Returns:
        Current timestamp in nanos or -1 if tracing is not enabled