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

how properly instrumenting a hybrid android app

igorl
Newcomer

I’m trying to instrument our android mobile app which
actually is a shell for another offline SPA web app. I did the following:

In App.java => OnCreate we call

intdynatraceResult = DynatraceUEM.startup(getApplicationContext(),
"eHopper
Shell", "http://qaserver2008:9998/ajax/", true, null);

if(dynatraceResult ==
DynatraceUEM.CPWR_Error_InvalidParameter){


Logger.error("DynatraceUEM.startup init error");


}

else


{


DynatraceUEM.enableCrashReporting(true);


}

There is a confusing part of the parameters – the
documentation says we need to pass an agentPath which is shown at System Profile Preferences > User Experience >
JavaScript Agent > Agent Location
.

Here’s what we are seeing:

I could not find anything like agent (e.g.,http://myhost.mydomain.com:8080/myApplication).

So I decided to try on my own several options:

Then in the ShellActivity => OnCreate() I try to
record something like this:

intdynatraceResult = DynatraceUEM.reportError("test
error", 1);

if(dynatraceResult !=
DynatraceUEM.CPWR_UemOn){


Logger.error("DynatraceUEM.startup init error");


}

try{

throw new
RuntimeException("test esception");

}catch(Exception e){

intres = DynatraceUEM.reportError(e.getMessage(), e);

}

UemAction createAction = DynatraceUEM.enterAction("create
shell activity");

After running all this code I could not see any records or
other signs in dynatrace neither on transaction flow nor in any specific places
I could imagine of (Please see the pictures below).

I’m pretty sure I did something wrong and definitely need
some help.

There is another thing I’ve observed: the Monitoring diagram
as well as others are very slow updating.

It’s been sometimes 10 or more minutes when some activities
are shown. Is there an option to forcibly refresh them?

5 REPLIES 5

andreas_grabner
Dynatrace Guru
Dynatrace Guru

Hi

Thanks for that detailed explanation. Let me try to help by explaining what this URL is all about.

The Dynatrace Mobile Agent that you compile into your Mobile App will collect data and then send it back to that URL that you specify in this first parameter - we call this the Monitor Signal URL/Path.

The Mobile Dynatrace Agent will send HTTP POST requests at certain intervals. The goal is that this URL ends up on your web server where you have a Dynatrace Web Server Agent installed. Assuming you have an Apache you would install our Web Server Agent and the Dynatrace Apache Module. Now - every request that makes it to Apache (including the one made by our Mobile Agent) will be seen by our DYnatrace Web Server Agent.

The Dynatrace Web Server Agent is expecting the Monitor Signal to come in on http://yourserver/dynaTraceMonitor - you can change that path however in the UEM Configuration Dialog that you have shown in your first screenshot. The Monitor URL Path however is the edit field below the JAvaScript Agent Location. So - if you want your mobile app to send back data to http://yourserver/dynaTraceMonitor you need to make sure that the Dynatrace Web Server Agent is installed on that web server and that you specify /ajax in the Monitor Path Edit Field.

The "Agent Location" option allows you to configure where the Dynatrace JavaScript Agent gets loaded from when you monitor an HTML App. If you server HTML content from a web server that has the dynatrace web server agent installed the web server agent will automatically add a <script> tag to the HTML with the URL to load the Dynatrace JavaScript agent as specified in that "Agent Location" text box. If your hybrid app is downloading HTML content from your web server you will see that the HTML will have a new <script> tag injected. The download of that javascript agent also works automatically.

I hope this all makes sense. I also encourage you to watch my Advanced UEM YouTube Tutorial that explains the background and architecture of UEM. There are more videos on my YouTube Channel: http://bit.ly/dttutorials

Last but not least - some links you might also find interesting

Andi

chintan_suhagiy
Participant

Hi Andreas,

can u suggest me manual instrumentation for hybrid application.I have read Doc on Hybrid Application Support but i am not able to understand where to insert code and all?

can i use " https://community.dynatrace.com/community/display... " this link for hybrid app

Hi Christian

For hybrid apps there are basically two things that have to happen in order to get dynatrace UEM capturing data

#1: You need to instrument your "native" part of the application. Just as pointed out in the doc you have to make code changes in your native mobile code to correctly load and configure our Mobile ADK. The calls to the ADK you have to add will tell our ADK where to send the capture data to, e.g: http://yourserver/yourapp/dynaTraceMonitor. For Android apps you also have to register the webview

#2: For the Web Part of your Hybrid app we have to load the Dynatrace JavaScript Agent into your page. This can either be done automatically through our automatic JAvaScript injection (this is the default way) or you can even manually add the <script> tag to your HTML pages in case automatic injection doesnt work for wahtever reason

Once both ADKs (native mobile + javascript) are loaded we will correctly capture native and web user actions from your hybrid app.

If you still struggle with getting your app instrumented - and if you are a customer with a support contract - I suggest you open a support ticket with our tech team. they can then help you

Andi

chintan_suhagiy
Participant

Hi Andreas,

As per your suggestion I tried manual instrumentation and added below code in html file.

<html> <head> <!-- load DT Agent Bootstrap file -->
<script src='[http/https]://<dynaTraceMonitor_path>/dtagent_bootstrap.js' type="text/javascript"></script>
<!-- OR (if bootstrap file not able to download dtagent.js and Dynatrace monitor file then hardcode it as below) -->
<script type="text/javascript" src="[http/https]://<dynaTraceMonitor_path>/dtagent630_q_1305.js" data-dtconfig="tp=500,50,0|cors=1|bandwidth=300_m|reportUrl=[http/https]://<dynaTraceMonitor_path>/dynaTraceMonitor"></script>
<!-- load DT Agent --> </head> ...
</html>

I have tried both the method first i tried with dtagent_bootstrap.js and then tried with dtagent630_q_1305.js but non of methods work for me.Still not able to find any visits.

Second point is that application is not using any webviews.

Hi Chintan

Would you mind opening a support ticket so that my colleagues can look into this. this might be the faster option here to get your app instrumented

andi