14 Dec 2021 11:25 PM - last edited on 15 Dec 2021 08:21 AM by MaciejNeumann
Hello, I've been using Dynatrace RUM for a while now and using "Inline Code" method. The drawback of manual injection is that every time I make any changes to the application configuration settings in Dynatrace, I have to update the monitoring code in my application which is not good and prone to errors.
I've bee looking into Dynatrace API and I think this can provide certain amount of automation and I don't need to change the code every time I change something. I've couple of questions on how this works -
Note - I am using Dynatrace managed and have 2 active gates running with a public load balancer which accepts all the RUM traffic from browsers
Let me know if anyone can shed some light on this. It will be a massive help.
15 Dec 2021 06:24 AM
Hello @shashank_b_agra ,
the API is able to provide you with the snippet you need to include. It's up to you how you are able to automate insertion of the code into your application. Typical process is - whenever the build and deploy task is executed in your app, your build script will pull the API for the Dynatrace JS code snippet.
Answers to your questions:
I'd really recommend the OneAgent approach - having OneAgent to insert the JS code for you in runtime. Did you ruled out this approach which is default?
15 Dec 2021 04:05 PM
Hi @Julius_Loman Thank you for your detailed response. We can't use one agent as our application is built on Angular and is serverless i.e. the pages are served from S3.
We kind of have a complex architecture where the front end is hosted on Angular which makes call to Strapi for content and then further XHR calls to downstream systems.
In the 2nd point you mentioned that XHR actions won't be loaded. Are you saying I won't be able to see any XHR requests in Dynatrace? Because if that is the case then Dynatrace RUM is not serving it's purpose. As a operations, we would like to see how the page is performing and for that I think we need to understand the XHR calls taking place on that page.
Could you elaborate on that please?
16 Dec 2021 07:52 AM
Hi @shashank_b_agra ,
OK I understand, you really need the agentless approach in your case.
With the XHR I meant there is not a loading of the Dynatrace JavaScript in the browser. XHRs will be captured of course if you have this option turned on in the application settings.
So whatever manual injection in the HTML code you are using, the Dynatrace JS gets loaded during Load actions only, but it's monitoring all the user actions (Load, XHR, Custom).
Actually the situation with updating the code is not that bad as it looks like. For many changes in the application settings you don't need to update the inline code. Mostly the update is required if:
16 Dec 2021 11:53 PM - last edited on 28 Mar 2023 09:18 AM by MaciejNeumann
Hi @Julius_Loman Thanks for the response again. I agree with you but manually updating the inline code is prone to errors and if we use the API, it will retrieve at the build time automatically and less chances of errors. I mean that is my point of view but I don't know how it will work because we haven't tested it.
I have one more concern. If by any chance the API endpoint is down or not responding then the application won't be able to fetch the code and we may lost the monitoring.
So basically during the build time only, we have to make sure that it fetches the code before it gets deployed.
Also, one more thing. My application which is built in Angular makes several XHR calls from the browser but Dynatrace is not logging them for some reason. Do you know if there is any config or property I need to change or add specifically to log these XHRs?
For example, We have a publically available page https://www.virginmedia.com/broadband/packages which if you load in the browser you will see lot of XHR calls in the developer tools network tab BUT they don't get logged in Dynatrace.
Any idea at all why?
Really appreciate if you can assist here with your thoughts.
17 Dec 2021 07:16 AM
Hi @shashank_b_agra ,
you fetch the inline code during build time. You don't have any runtime dependency on the API from your app. You need to handle situations such as api token not valid or dynatrace environment is not reachble from your build system. They are unlikely, but of course may happen.
The second question - this may occur for several reasons, for answers I'd need to see the waterfall in Dynatrace and the browser's developer tools.
Julius
17 Dec 2021 09:48 AM
Hi @Julius_Loman Answers below -
I've a ticket raised with Dynatrace to investigate this behaviour because If i go into the waterfall analysis of that page, I can see all the XHR calls logged there in the exactly same manner they are called in browser. It's just on the application page where they are not showing. Let's see what they come up with.
Also one last help 🙂
I know if i use inline code then I would have to update my snippet everytime I make changes in Application settings under Capturing -> Advanced setup, BUT what if i use CodeSnippet (deferred) mode?
How does that work? Dynatrace says if you use this format then the changes will automatically reflect in customers browsers. Is it because everytime customer loads the page, the snippet or monitoring code gets loaded at runtime from Dynatrace.
For example - the snippet looks like this at first -
da.cfg="app=XXXXXXX|cors=1|rcdec=1209600000|featureHash=A2Vfgqru|cux=1|vcv=2|reportUrl=****
Now I change a param in advanced setup and remove cux=1, then it looks like this -
da.cfg="app=XXXXXXX|cors=1|rcdec=1209600000|featureHash=A2Vfgqru|vcv=2|reportUrl=
you can see that param is gone. But how will it gets reflected in customer browser unless we change the snippet in HTML? I also get a yellow warning message as attached which Dynatrace says that is only for inline code and can be ignored.
Really appreciate if you can shed some light as I have been getting different answers everywhere.
Best Regards,
Shashank
27 Dec 2021 09:19 PM
Hi @shashank_b_agra ,
if I remember the setting correctly, the deferred mode tries to be a non-blocking. This is described here and you can see the differences between the options https://www.dynatrace.com/support/help/how-to-use-dynatrace/real-user-monitoring/setup-and-configura...
In your case I believe you still need to update your pages with an updated tag reflecting the configuration.
For the missing requests in waterfall - you will probably need to talk to support or check the stack (initiator) in the developer options. I think it's likely in from a JavaScript from an iframe that does not have the Dynatrace JavaScript.
Regards
Julius