From 560cf46db47511d515c6016cab4370601e980e77 Mon Sep 17 00:00:00 2001 From: Jakub Malinowski Date: Tue, 30 Jul 2024 17:21:04 +0200 Subject: [PATCH 1/5] Manual navigation tracking for Android --- .../manual-rum-android-instrumentation.rst | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst b/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst index 9a662e0d9..bebddd3a9 100644 --- a/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst +++ b/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst @@ -154,6 +154,58 @@ For example, the following activity appears with the ``screen.name`` attribute s ... } +.. _android-rum-manual-navigation-tracking: + +Manually track navigation events +===================================== + +By default, the Android RUM agent follows the view lifecycle of ``Fragment`` and ``Activity`` instances, and certain UI frameworks, e.g. Jetpack Compose, do not use that view lifecycle. In that case, starting with the version 1.6.0, :code:`experimentalSetScreenName()` can be used to explitly signal that navigation has occurred. Method name is prefixed with :code:`experimental` to denote that this API might change in the future, possibly even between minor releases. + +In general, upon a non-``Fragment``, non-``Activity`` navigation event, the application developer calls: + +.. code-block:: java + + SplunkRum.getInstance().experimentalSetScreenName(screenName); + +which both sends a navigation span to RUM, and remembers the screen name which will then be assigned as an attribute on the later spans. + +Once the explicit screen name is set, it overrides the default view livecycle tracking. If your application consists of both ``Activity`` and non-``Activity`` views, then upon exiting the view with non-``Activity`` navigation, the explicit screen name must be cleared: + +.. code-block:: java + + // doubled to clear both the last view and the previous last view + SplunkRum.getInstance().experimentalSetScreenName(null) + SplunkRum.getInstance().experimentalSetScreenName(null) + +And if you'd like to track these in RUM, ``Restarted`` and ``Resumed`` events must then also be signalled explicitly, for example: + +.. code-block:: kotlin + + override fun onResume() { + super.onResume() + // in this case you need to store lastScreen yourself + if (lastScreen != null) { + SplunkRum.getInstance().experimentalSetScreenName(lastScreen, "Resumed") + } + } + +When using Jetpack Compose, the active route can be used as a screen name, and the code will depend on the implementation, but for a simplified example see: + +.. code-block:: kotlin + + val navController = rememberNavController() + val currentBackEntry by navController.currentBackStackEntryAsState() + val currentRoute = currentBackEntry?.destination?.route + + LaunchedEffect(currentRoute) { + if (currentRoute != null) { + lastRoute = currentRoute + SplunkRum.getInstance().experimentalSetScreenName(currentRoute) + } + } + +Finally, a complete example of manually tracking navigation with Jetpack Compose `can be found here `_. + .. _android-rum-error-reporting: Configure error reporting From 6d52013f5a0dc299b4507f24fdccbc4f4369ec49 Mon Sep 17 00:00:00 2001 From: Charlie Cai <43084032+caiicaii@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:43:51 -0700 Subject: [PATCH 2/5] Fix public key typo --- gdi/opentelemetry/install-the-collector.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdi/opentelemetry/install-the-collector.rst b/gdi/opentelemetry/install-the-collector.rst index 6e78f8031..0ae593613 100644 --- a/gdi/opentelemetry/install-the-collector.rst +++ b/gdi/opentelemetry/install-the-collector.rst @@ -72,7 +72,7 @@ If you need to verify and trust your software package, use the following public VbbHBd5Xo9Ge5BjwXOcoDhvUQqNJdLBJruhvhn7Ogy5Paw5TGhdawfjxT2yXeqbE Juv6qdo/mSimkpR8lkQT7OsfAQbCPeyFvZKb22hXj6tCTVJncwCJLe/FBdXJhRep Y6NEdmKZLGodXv4zLNVr7SkCAwEAAQ== - -----END PUBLIC KEY---- + -----END PUBLIC KEY----- For older Collector versions, use this public key: @@ -234,4 +234,4 @@ See also the following documents to understand how the Collector works, and how The Collector operates using these environmental variables and internal metrics: * :ref:`collector-env-var` -* :ref:`metrics-internal-collector` \ No newline at end of file +* :ref:`metrics-internal-collector` From d04aead0f403bd06296ba3db30bdba1d476f4579 Mon Sep 17 00:00:00 2001 From: Tracey <57269043+tcarter-splunk@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:58:14 -0700 Subject: [PATCH 3/5] Update gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst Co-authored-by: jason plumb <75337021+breedx-splk@users.noreply.github.com> --- .../rum/android/manual-rum-android-instrumentation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst b/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst index bebddd3a9..950c2a876 100644 --- a/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst +++ b/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst @@ -167,7 +167,7 @@ In general, upon a non-``Fragment``, non-``Activity`` navigation event, the appl SplunkRum.getInstance().experimentalSetScreenName(screenName); -which both sends a navigation span to RUM, and remembers the screen name which will then be assigned as an attribute on the later spans. +This sends a navigation span to RUM and remembers the screen name for subsequent spans. Once the explicit screen name is set, it overrides the default view livecycle tracking. If your application consists of both ``Activity`` and non-``Activity`` views, then upon exiting the view with non-``Activity`` navigation, the explicit screen name must be cleared: From ab52b4f046f70bbcfefaafee74d4c10f5f275a0e Mon Sep 17 00:00:00 2001 From: Tracey <57269043+tcarter-splunk@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:58:34 -0700 Subject: [PATCH 4/5] Update gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst Co-authored-by: jason plumb <75337021+breedx-splk@users.noreply.github.com> --- .../rum/android/manual-rum-android-instrumentation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst b/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst index 950c2a876..bb01152b7 100644 --- a/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst +++ b/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst @@ -169,7 +169,7 @@ In general, upon a non-``Fragment``, non-``Activity`` navigation event, the appl This sends a navigation span to RUM and remembers the screen name for subsequent spans. -Once the explicit screen name is set, it overrides the default view livecycle tracking. If your application consists of both ``Activity`` and non-``Activity`` views, then upon exiting the view with non-``Activity`` navigation, the explicit screen name must be cleared: +Once the explicit screen name is set, it overrides the default view livecycle tracking. If your application consists of both ``Activity`` and non-``Activity`` views, you must clear the explicit screen name when exiting the non-``Activity`` view: .. code-block:: java From 2f048dc2bc27309eee11dfb73e029820441b949d Mon Sep 17 00:00:00 2001 From: Tracey <57269043+tcarter-splunk@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:17:07 -0700 Subject: [PATCH 5/5] Update manual-rum-android-instrumentation.rst updated PR suggestions from non-Splunk contributor to align with Splunk style guide --- .../manual-rum-android-instrumentation.rst | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst b/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst index bb01152b7..072abd6ee 100644 --- a/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst +++ b/gdi/get-data-in/rum/android/manual-rum-android-instrumentation.rst @@ -69,7 +69,7 @@ By default, the Android RUM agent doesn't automatically link traces to users of You can identify users by adding global attributes from the OpenTelemetry specification, such as ``enduser.id`` and ``enduser.role``, to your spans. -The following examples show how to add identification metadata as global attributes when initializing the agent or after you've initialized it, depending on whether user data is accessible at initialization: +The following examples show how to add identification metadata as global attributes when initializing the agent or after initializing it, depending on whether user data is accessible at initialization: Add identification metadata during initialization -------------------------------------------------- @@ -177,19 +177,7 @@ Once the explicit screen name is set, it overrides the default view livecycle tr SplunkRum.getInstance().experimentalSetScreenName(null) SplunkRum.getInstance().experimentalSetScreenName(null) -And if you'd like to track these in RUM, ``Restarted`` and ``Resumed`` events must then also be signalled explicitly, for example: - -.. code-block:: kotlin - - override fun onResume() { - super.onResume() - // in this case you need to store lastScreen yourself - if (lastScreen != null) { - SplunkRum.getInstance().experimentalSetScreenName(lastScreen, "Resumed") - } - } - -When using Jetpack Compose, the active route can be used as a screen name, and the code will depend on the implementation, but for a simplified example see: +When using Jetpack Compose, You can use the active route as a screen name, and the code will depend on the implementation. The following is a simplified example: .. code-block:: kotlin