US-12625684-B2 - Automatic real user monitoring (RUM) instrumentation
Abstract
Systems and methods are disclosed to develop and use a tool to enable an application package to be instrumented with automatic real user monitoring (RUM) without accessing the original source code. A package, such as Android application bundle (AAB) or Android package kit (APK), is imported and decoded and a generated source code file and/or manifest is obtained. Instrumentation is then added at a location corresponding to a code signature in the generated source code file (e.g., an operation to be instrumented before and/or after the operation). The generated source code file is then compiled and packaged into an APK and/or AAB file. The resulting application package is available for downloading, installation, and use on user devices with the instrumentation having been automatically added and without access to the original source code.
Inventors
- YU-DAN LIN
- Bing Zhang
- Hao Liu
- Jin-Hong Zhang
Assignees
- MICRO FOCUS LLC
Dates
- Publication Date
- 20260512
- Application Date
- 20231010
Claims (20)
- 1 . A method, comprising: accessing an application package comprising executable application code and a machine-readable manifest; extracting the machine-readable manifest from the application package; decoding the machine-readable manifest into an intermediate manifest; matching a portion of the intermediate manifest to an object signature; inserting, in the intermediate manifest, instrument code relative to the object signature to produce an instrumented manifest; encoding the instrumented manifest into an instrumented machine-readable manifest; extracting the executable application code from the application package; processing the executable application code to identify an instrumentation signature, wherein processing the executable application code includes decompiling the executable application code into a generated source code file; inserting instrumentation code relative to the instrumentation signature to produce instrumented executable application code; and packaging the instrumented executable application code and the instrumented machine-readable manifest into an instrumented application package.
- 2 . The method of claim 1 , wherein the executable application code comprises binary Dalvik bytecode (DEX).
- 3 . The method of claim 1 , wherein the generated source code file comprises Smali text.
- 4 . The method of claim 1 , further comprising inserting the instrumentation code in at least one of directly before or directly after an instrumentation signature, respectively.
- 5 . The method of claim 1 , wherein the machine-readable manifest comprises Android layout view (AXML) content.
- 6 . The method of claim 1 , wherein at least one of the intermediate manifest and the instrumented manifest comprise extensible markup language (XML) instructions.
- 7 . The method of claim 1 , wherein packaging the instrumented executable application code into the instrumented application package further comprises: receiving a package type; and in response to the package type, packaging the instrumented executable application code into the instrumented application package having the package type.
- 8 . The method of claim 7 , wherein the package type is selected from a group comprising Android application bundle (AAB) or Android package kit (APK).
- 9 . The method of claim 1 , wherein extracting the executable application code from the application package further comprises extracting at least one of a resource or an asset from the application package.
- 10 . The method of claim 9 , wherein packaging the instrumented executable application code into the instrumented application package further comprises packaging the at least one of the resource or the asset in the instrumented application package.
- 11 . A method, comprising: accessing an application package comprising executable manifest; extracting the executable manifest from the application package; decoding the executable manifest into an intermediate manifest; matching a portion of the intermediate manifest to an object signature; inserting, in the intermediate manifest, in at least one of before the object signature and after the object signature an instrumentation code to produce an instrumented manifest; encoding the instrumented manifest into an instrumented machine-readable manifest; extracting an executable application code from the application package; decompiling the executable application code into a generated source code file; and packaging the instrumented machine-readable manifest into an instrumented application package.
- 12 . The method of claim 11 , wherein the intermediate manifest comprises an Android manifest (AXML).
- 13 . The method of claim 11 , wherein the instrumented manifest comprises an extensible markup language (XML).
- 14 . The method of claim 11 , further comprising: matching a portion of the generated source code file to an instrumentation signature; inserting, in the generated source code file, in at least one of before the instrumentation signature and after the instrumentation signature, an instrumentation code to produce an instrumented source code; compiling the instrumented source code into an instrumented executable application code; and packaging the instrumented executable application code into the instrumented application package.
- 15 . The method of claim 14 , wherein the executable application code comprises binary Dalvik bytecode (DEX).
- 16 . The method of claim 14 , wherein packaging the instrumented executable application code into the instrumented application package further comprises: receiving a package type; and in response to the package type, packaging the instrumented executable application code into the instrumented application package having the package type.
- 17 . The method of claim 16 , wherein the package type is selected from a group comprising Android application bundle (AAB) or Android package kit (APK).
- 18 . The method of claim 11 , wherein the generated source code file comprises Smali text.
- 19 . A system, comprising: a data storage maintaining an application package comprising an executable manifest; a processor coupled to a computer memory and having stored thereon instructions to cause the processor to: access the application package from the data storage; extract the executable manifest from the application package; decode the executable manifest into an intermediate manifest; match a portion of the intermediate manifest to an object signature; insert, in the intermediate manifest in at least one of before the object signature and after the object signature, an instrumentation code to produce an instrumented manifest; encode the instrumented manifest into an instrumented machine-readable manifest; extract an executable application code from the application package; decompile the executable application code into a generated source code file; package the instrumented machine-readable manifest into an instrumented application package; and store the instrumented application package in the data storage.
- 20 . The system of claim 19 , wherein the intermediate manifest comprises an Android manifest (AXML) and the instrumented manifest comprises an extensible markup language (XML).
Description
FIELD OF THE DISCLOSURE The invention relates generally to systems and methods for instrumenting an application and particularly to automatic application of instrumentation to an application packaged in an application package. BACKGROUND Automatic Real User Monitoring (RUM) is a monitoring tool for Android-based applications that tracks user interactions, identifies performance issues, detects errors, and improves user experience. To make the Android application observable, it must be instrumented: That is, the source code of mobile application emits traces, metrics, and/or logs. A RUM instrument has the ability to track and report on how users interact with the application to provide insight into how the application is performing in real-world scenarios. Despite the advantages, prior art RUM instrument solutions require modifications to the source code and corresponding additional skills, like how to use a third-party RUM software development kit (SDK) and how to use the imported libraries. In addition, application providers (instead of developers) may want to add instrumentation after the Android application is packaged. Prior art RUM instrument solutions for Android apps require modification of the source code to implement instrumentation. These solutions can be complex, skill-intensive, and time-consuming to implement and may introduce errors or bugs into the codebase. There are several tools to implement RUM, in particular, “OpenTelemetry” (or “OTEL”). For example, OTEL libraries provide APls for creating spans, which are units of work in an application that are timed and traced. This typically involves adding a few lines of code to the application and configuring an agent with the appropriate settings. After these code changes are made, the code is then packaged using the Android Package Kit (APK) file format with an OpenTelemetry SDK and/or Android Package Kit (APK) file and then published to be available for download, such as via Google Play, and installed on users' Android devices. SUMMARY Prior art instrumentation tools require implementation by highly skilled developers. While prior art solutions may have a limited ability to insert RUM code into a source code file, the prior art solutions cannot be added after packaging, such as to an Android application bundle (AAB) or Android package kit (APK) file. As a result, application owners cannot implement the RUM instrument except by asking help from application developers. These and other needs are addressed by the various embodiments and configurations of the present invention. The present invention can provide a number of advantages depending on the particular configuration. These and other advantages will be apparent from the disclosure of the invention(s) contained herein. In one embodiment, systems and methods are disclosed to develop and use a tool to enable a user (who may have, but is not required to utilize, application development abilities) to import an Android AAB or APK file and run the tool to inject the instrument into the file. The instrumentation injection process may be customized, such as to include or exclude particular instrumentation and enable the receipt of the corresponding information necessary for a particular application. This approach differs from traditional RUM instruments in that it provides a more cost-saving, user-friendly, skill-reduced approach to implement RUM monitoring. The systems and methods disclosed herein provide various advantages including, but not limited to: No source code modification needed: Unlike prior art solutions that require application developers to modify their code, the solution herein automatically injects the RUM instrumentation without changing the original source code, as such modifications are performed on post-build files. As a benefit, application owners or other non-developers may implement instrumentation into the Android application after coding is complete. It should be appreciated that an “application owner,” for purposes herein, refers to one or more individuals or a business having access to an application package for which instrumentation is to be provided-actual ownership of the application may be present but is not required. Supports Android AAB and APK files: Solutions herein can utilize Android AAB or APK files as the application input, in order to insert instrumentation, and output either (or both) an Android AAB or APK file therefrom. As a result, integration of RUM instrumentation into existing package workflows is provided regardless of the packaging format. Customizable instrumentation: Solutions herein allow the instrumentation to be customized in order to collect all necessary information without wasting resources collecting unnecessary information. Reduces effort: The solutions provided herein automate the instrumentation process and, as a result, save application developer time and effort, allowing them to focus on other aspects of their application. User-friendly