Class Dynatrace


  • public class Dynatrace
    extends Object
    Dynatrace Manual Instrumentation API for Android
    • Method Detail

      • startup

        public static void startup​(Activity activity,
                                   com.dynatrace.android.agent.conf.Configuration configuration)
        Initializing the mobile agent for capturing and reporting data. This method should be used, when the agent is not immediatly started in the application startup phase.
        Parameters:
        activity - instance of the currently active activity
        configuration - configuration object created by AppMonConfigurationBuilder or DynatraceConfigurationBuilder
        Since:
        8.231
        See Also:
        startup(Application, Configuration)
      • shutdown

        public static void shutdown()
        Shuts down the mobile agent gracefully. All data capturing stops. The mobile agent also attempts to flush the data for up to 5 seconds.
      • getCaptureStatus

        public static boolean getCaptureStatus()
        Get the current data capture state
        Returns:
        true, if data is captured
      • setGpsLocation

        public static void setGpsLocation​(Location location)
        Saves the given GPS location for reporting along with the captured data.
        Parameters:
        location - to be saved
      • getRequestTagHeader

        public static String getRequestTagHeader()
        Returns the Dynatrace request tag header name to be used in conjunction with the value returned by getRequestTag().
        Returns:
        the request tag header name
      • getRequestTag

        public static String getRequestTag()
        Generates a Dynatrace request tag for a web request, which has to be manually added as http header (header key can be obtained with the method getRequestTagHeader()). The tag value is evaluated by the corresponding web server agent. The Dynatrace server will link the server-side PurePath data with a mobile user action.

        Since there is no explicit action, the web request is correlated to an action according to the following rule:

        1. If there is an open action in the current thread at the time the request is tagged, the web request is assigned (by the mobile agent) to the open action.
        2. Only AppMon, if there is no open action in the current thread, the web request is assigned (by the AppMon Server) to an action that calls its leaveAction() method in the same thread where the tagging is done. The tagging time must fall between the action enter and leave times.
        3. If neither of the preceding cases applies, the web request is not assigned to any action.
        Returns:
        the request tag value or an empty string, if the mobile agent is not active
        See Also:
        getRequestTagHeader(), DTXAction.getRequestTag()
      • tagRequest

        public static void tagRequest​(HttpURLConnection conn)
        Places a Dynatrace request tag on the web request, which is evaluated by the corresponding web server agent. The Dynatrace server will link the server-side PurePath data with a mobile user action.

        Since there is no explicit action, the web request is correlated to an action according to the following rule:

        1. If there is an open action in the current thread at the time the request is tagged, the web request is assigned (by the mobile agent) to the open action.
        2. If there is no open action in the current thread, the web request is assigned (by the Dynatrace Server) to an action that calls its leaveAction() method in the same thread where the tagging is done. The tagging time must fall between the action enter and leave times.
        3. If neither of the preceding cases applies, the web request is not assigned to any action. In this case the server-side PurePath data is not linked to the mobile user action (but it can be identified as mobile traffic in the transaction flow).
        Parameters:
        conn - the request tag will be added as header to the connection
        See Also:
        DTXAction.tagRequest(HttpURLConnection)
      • enterAction

        public static DTXAction enterAction​(String actionName)
        Similar to enterAction(String, DTXAction). But the action will be generated as root action.
        Parameters:
        actionName - name of the action
        Returns:
        A non null action instance.
      • enterAction

        public static DTXAction enterAction​(String actionName,
                                            DTXAction parentAction)
        This creates an action object for reporting the time elapsed between two user-defined times. For example, you can use the methods enterAction and leaveAction to determine how long it takes to pull content from a remote server. Within the action scope, you can have visibility to the corresponding backend transactions. Also other event types (reportEvent, reportValue and reportError) can be reported within the context of the action object, thus creating a series of events within an action scope.

        You must call leaveAction on an action object to complete an action.

        Parameters:
        actionName - name of the action
        parentAction - a parent action or null to create a new 'root' action object
        Returns:
        A non null action instance.
      • endVisit

        public static void endVisit()
        Can be called to end the current visit and start a new visit. All current actions are closed and sent to the server.
      • reportError

        public static void reportError​(String errorName,
                                       int errorCode)
        Similar to DTXAction.reportError(String, int). But the error event is reported as root action.
        Parameters:
        errorName - error name
        errorCode - integer error code
      • flushEvents

        public static void flushEvents()
        Call this function to flush all collected events immediately. To reduce network chatter, the collected events are usually sent in packages where the oldest event has an age of up to 2 minutes (the default; the maximum age can be configured). Using this function, you can force sending of all collected events regardless of their age.
      • identifyUser

        public static void identifyUser​(String userId)
        The current visit/session will be tagged with the provided user id. The value will not be stored and has to be renewed for every new session.
        Parameters:
        userId - a unique id that allows you to identify the current user. If userId is null or empty, then the user tag will be removed from the session.
      • identifyUser

        @Deprecated
        public static void identifyUser​(String userId,
                                        DTXAction parentAction)
        Deprecated.
        As of version 8.215, use identifyUser(String) instead
        The current visit/session will be tagged with the provided user id. The value will not be stored and has to be renewed on every agent startup.
        Parameters:
        userId - a unique id that allows you to identify the current user. If userId is null or empty, then the user tag will be removed from the session.
        parentAction - The parent action for the user identify event
      • applyUserPrivacyOptions

        public static void applyUserPrivacyOptions​(UserPrivacyOptions userPrivacyOptions)
        Creates a new session with the specified privacy settings and stores the privacy settings for future sessions.

        This method can only be used, when user opt-in feature is enabled. This method call has no effect if the given privacy settings are identical to the previously specified privacy settings.

        Parameters:
        userPrivacyOptions - the new privacy settings from the user
        Since:
        8.191
        See Also:
        ConfigurationBuilder.withUserOptIn(boolean)
      • isCrashReportingOptedIn

        @Deprecated
        public static boolean isCrashReportingOptedIn()
        Deprecated.
        As of version 8.191, replaced by getUserPrivacyOptions()
        Returns the current privacy setting for crash reporting. This method will always return true, when the user optin feature is not used.
        Returns:
        current privacy setting for crash reporting
        Throws:
        IllegalStateException - if the agent is not started
      • modifyUserAction

        public static void modifyUserAction​(UserActionModifier modifier)
        Allows to modify the currently pending user action. If there is no user action pending or if it is already closed upon modification, no modification takes place.
        Parameters:
        modifier - modifications that should be applied to the newly created user action
        Since:
        8.189
      • instrumentWebView

        public static void instrumentWebView​(WebView webView)
        Instruments the given WebView to allow communication between the RUM JavaScript tag and OneAgent for Android.

        For hybrid apps with the RUM JavaScript tag inside a WebView, it is required to execute this method for every WebView that contains the RUM JavaScript tag. Without this method call it can't be ensured that the monitoring data will be combined into same session.

        Note that this method has no effect for API level 15 and 16 because of security reasons.

        Parameters:
        webView - the web view that should be instrumented
        Since:
        8.191
        See Also:
        ConfigurationBuilder.withHybridMonitoring(boolean)