Interface Action

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable
    All Known Subinterfaces:
    RootAction
    All Known Implementing Classes:
    BaseActionImpl, LeafActionImpl, NullRootAction, RootActionImpl

    public interface Action
    extends java.io.Closeable
    This interface provides functionality to create (child) Actions, report events/values/errors and tracing web requests.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Action cancelAction()
      Cancels this Action.
      long getDurationInMilliseconds()
      Get the action's duration in milliseconds.
      Action leaveAction()
      Leaves this Action.
      Action reportError​(java.lang.String errorName, int errorCode)
      Reports an error with a specified name and error code.
      Action reportError​(java.lang.String errorName, java.lang.String causeName, java.lang.String causeDescription, java.lang.String causeStackTrace)
      Reports an error with a specified name and fields describing the cause of this error.
      Action reportError​(java.lang.String errorName, java.lang.Throwable throwable)
      Reports an error with a specified name and a Throwable.
      Action reportEvent​(java.lang.String eventName)
      Reports an event with a specified name (but without any value).
      Action reportValue​(java.lang.String valueName, double value)
      Reports a double value with a specified name.
      Action reportValue​(java.lang.String valueName, int value)
      Reports an int value with a specified name.
      Action reportValue​(java.lang.String valueName, long value)
      Reports a long value with a specified name.
      Action reportValue​(java.lang.String valueName, java.lang.String value)
      Reports a String value with a specified name.
      WebRequestTracer traceWebRequest​(java.lang.String url)
      Allows tracing and timing of a web request handled by any 3rd party HTTP Client (e.g.
      WebRequestTracer traceWebRequest​(java.net.URLConnection connection)
      Traces a web request - which is provided as a URLConnection - and allows adding timing information to this request.
      • Methods inherited from interface java.io.Closeable

        close
    • Method Detail

      • reportEvent

        Action reportEvent​(java.lang.String eventName)
        Reports an event with a specified name (but without any value).

        If given eventName is null or an empty String then no event is reported to the system.

        Parameters:
        eventName - name of the event
        Returns:
        this Action (for usage as fluent API)
      • reportValue

        Action reportValue​(java.lang.String valueName,
                           int value)
        Reports an int value with a specified name.

        If given valueName is null or an empty String then no event is reported to the system.

        Parameters:
        valueName - name of this value
        value - value itself
        Returns:
        this Action (for usage as fluent API)
      • reportValue

        Action reportValue​(java.lang.String valueName,
                           long value)
        Reports a long value with a specified name.

        If given valueName is null or an empty String then no event is reported to the system.

        Parameters:
        valueName - name of this value
        value - value itself
        Returns:
        this Action (for usage as fluent API)
      • reportValue

        Action reportValue​(java.lang.String valueName,
                           double value)
        Reports a double value with a specified name.

        If given valueName is null or an empty String then no event is reported to the system.

        Parameters:
        valueName - name of this value
        value - value itself
        Returns:
        this Action (for usage as fluent API)
      • reportValue

        Action reportValue​(java.lang.String valueName,
                           java.lang.String value)
        Reports a String value with a specified name.

        If given valueName is null or an empty String then no event is reported to the system.

        Parameters:
        valueName - name of this value
        value - value itself The value can be null or an empty String.
        Returns:
        this Action (for usage as fluent API)
      • reportError

        Action reportError​(java.lang.String errorName,
                           int errorCode)
        Reports an error with a specified name and error code.

        If given errorName is null or an empty String then no event is reported to the system.

        Parameters:
        errorName - name of this error
        errorCode - numeric error code of this error
        Returns:
        this Action (for usage as fluent API)
      • reportError

        Action reportError​(java.lang.String errorName,
                           java.lang.String causeName,
                           java.lang.String causeDescription,
                           java.lang.String causeStackTrace)
        Reports an error with a specified name and fields describing the cause of this error.

        If given errorName is null or an empty string then no event is reported to the system. If the causeDescription is longer than 1000 characters, it is truncated to this value. If the causeStackTrace is longer than 128.000 characters, it is truncated according to the last line break.

        Parameters:
        errorName - name of this error
        causeName - name describing the cause of the error. E.g. the class name of a caught exception.
        causeDescription - description what caused the error E.g. Throwable.getMessage() of a caught exception.
        causeStackTrace - stack trace of the error E.g. the Throwable stack trace
        Returns:
        this Action (for usage as fluent API)
      • reportError

        Action reportError​(java.lang.String errorName,
                           java.lang.Throwable throwable)
        Reports an error with a specified name and a Throwable.

        If given errorName is null or an empty string then no event is reported to the system.

        Parameters:
        errorName - name of this error
        throwable - Throwable causing this error
        Returns:
        this Action (for usage as fluent API)
      • traceWebRequest

        WebRequestTracer traceWebRequest​(java.net.URLConnection connection)
        Traces a web request - which is provided as a URLConnection - and allows adding timing information to this request. If the web request is continued on a server-side Agent (e.g. Java, .NET, ...) this Session will be correlated to the resulting server-side PurePath.

        If given connection is null then no event is reported to the system.

        Parameters:
        connection - the URLConnection of the HTTP request to be tagged and timed
        Returns:
        a WebRequestTracer which allows adding timing information
      • traceWebRequest

        WebRequestTracer traceWebRequest​(java.lang.String url)
        Allows tracing and timing of a web request handled by any 3rd party HTTP Client (e.g. Apache, Google, Jetty, ...). In this case the Dynatrace HTTP header (OpenKitConstants.WEBREQUEST_TAG_HEADER) has to be set manually to the tag value of this WebRequestTracer.
        If the web request is continued on a server-side Agent (e.g. Java, .NET, ...) this Session will be correlated to the resulting server-side PurePath.

        If given url is null or an empty string then no event is reported to the system.

        Parameters:
        url - the URL of the web request to be tagged and timed
        Returns:
        a WebRequestTracer which allows getting the tag value and adding timing information
      • leaveAction

        Action leaveAction()
        Leaves this Action.
        Returns:
        the parent Action, or null if there is no parent Action
      • cancelAction

        Action cancelAction()
        Cancels this Action.

        Canceling an action is similar to leaving an action, except that the data and all unfinished child objects are discarded instead of being sent.

        Returns:
        the parent Action, or null if there is no parent Action
      • getDurationInMilliseconds

        long getDurationInMilliseconds()
        Get the action's duration in milliseconds.

        The duration of an Action is equal to the current timestamp - start timestamp, if the action is still open, or end timestamp - start timestamp if leaveAction() or cancelAction() was already called.

        Returns:
        The duration of this Action.