cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to instrument network plugins in cordova?

c_traina
Newcomer

I tried to instrument an hybrid application with the dynatrace cordova plugin. It worked fine and all the actions get traced, except the external xhr actions.

The problem is that the plugin expects a hybrid xhr call, like if it was in the browser. But, in this case, all the network calls are managed by an external native plugin that can't be removed.

The plugin that we are using is advanced-http, if it could be useful.

I'd like to know if there is a way to trace the requests invoked inside a plugin, or if there's a workaround to get a full analytics in the console.


Thank you


8 REPLIES 8

skrystosik
DynaMight Guru
DynaMight Guru

As Cordova plugin is basically infecting RUM JS agent into web part of your application, only Idea I have is using custom user actions / manual instrumentation:

https://www.dynatrace.com/news/blog/create-and-monitor-custom-user-actions/

But this means that you will need to mark all XHR’s as custom actions what can be hard. Maybe writing wrapper for this plugin which will be instrumented is solution here?

Sebastian


Regards, Sebastian

matthias_hochri
Dynatrace Pro
Dynatrace Pro

The Auto instrumentation of the Mobile Agent will catch the request.


Using this plugin has one downside with Dynatrace. The JSAgent will not report a user action anymore, as it only reports user actions with XHR. The XHR is now happening on the native side and will therefor be catched by the Mobile Agent. But you wont see this request in the user session as there is no connected user action. You will see the request of course in the application overview.


c_traina
Newcomer

Thank you both for the fast and complete answers and thank you for understanding the problem.

@Matthias H. Where can I find the services called in the application overview?

In the dashboard I can select two different application, since the native part and the webview have been instrumented separately. If I select the webview app, I don't find any "called services" item. If I select the native app I find the item, but I don't find any request inside.

Am I doing something wrong?


@Sebastian K. In our architecture, we are using some IBM WAS that will be instrumented to have a more complete overview of services called. Using custom actions, I'm afraid that dynatrace won't be able to join the analytics of both the parts and it could present the result as two independent applications.

I had also thought about writing a wrapper, but I want to keep this solution as last.


As you already noticed the services should be in the Mobile Application. This is because your request are done by the native side and not within web. The Web Request should also be visible within the Mobile Application. (Click on Network Performance and then select the domain, here you should see the different requests)


Too bad, in that page I only see the requests performed by the native application. Isn't this a sign that the plugin hasn't been instrumented?


You said you are using advanced-http. How do you make the other requests?


The native application and the hybrid application are two separate entities, the native application performs its requests with its own solutions, and the hybrid application is agnostic about it. In this scenario, the native network is traced while the hybrid network is not.


The cordova plugin is only used by the hybrid application


Okay. I misunderstood then. So you are saying that you have a plain native application and a hybrid application. But again you said above that you are using the advanced-http plugin.

The advanced-http plugin gives a Hybrid application the option to make a network request natively. According to my understanding (and the GitHub docs) it uses the Android http-request library, which uses HttpUrlConnection. The Mobile Agent will detect the usage of HttpUrlConnection and will instrument this. As the Cordova plugin also triggers this instrumentation the requests should be tracked. If this really doesn't work - I would like to continue via support case where we have a deeper look at the problem.

So making a request with advanced-http plugin contains no JS interaction or what so ever. The whole connection happens on the native side.


Featured Posts