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

Determining injection format and type.

Jordi2
Visitor

Hello everyone!

Context

Dynatrace is set up within the company and applications have been created, which are successfully receiving RUM traffic. However, some applications that are manually injected have been created through the creation of detection rules, meaning they are presented as auto injected by Dynatrace.

Problem statement

I need to accurately determine whether each application has been injected manually or automatically, along with identifying the specific injection format (OneAgent JS Tag, JS Tag, Inline code, or code snippet).

This will help me, among other things, determine which manually injected applications were created through detection rules and, hence, should be re-created as agentless.

Methodology

To ascertain the type and format of an injection, I utilize the following function in the Developer Tools console of the web page associated with the application: dT_.gdi() (Source). The output provides various details, for instance:

image-2025-2-19_10-52-11.png

In my exploration of this function, I have identified a few key points:

Conflict with Dynatrace documentation

According to the documentation, "For automatic injection, different injection formats of the RUM JavaScript look different, but what they all have in common is the data-dtconfig attribute." (source: Rum JavaScript injection).

However, this contradicts my findings with dT_.gdi(), as the automatically injected CodeSnippetDeferred and CodeSnippetSync scripts do not contain this attribute, yet dT_.gdi() recognizes them correctly.

My conclusion on this part is that the documentation is wrong.

Wrongly determined format

dT_.gdi() will determine a web application with a CodeSnippetDeferred injection as a CodeSnippetSync injection. From my testings, dT._gdi() seems to be looking for the defer keyword, which is not present in the CodeSnippetDeferred. Indeed, the only difference between both code snippets is the presence of the keyword async in the CodeSnippetDefered.

My conclusion on this part is that dT_.gdi() is wrong.

Questions

Given this, my questions are the following:

  1. How trustable is dT_.gdi()? Is it deprecated?
  2. How do I accurately determine the injection format and type? For now, I am relying on the dT_.gdi() function while inspecting more deeply the injected element in the HTML when I encounter use cases where dT_.gdi() might be wrong. However, I have the impression that there should be a more straightforward solution to this.

 

Thank you in advance for your feedback .

6 REPLIES 6

simon_schatka
Dynatrace Advisor
Dynatrace Advisor

Hi

I just retested everything and can not confirm your findings regarding dT_.gdi(). (I can however confirm that the documentation regarding the data-dtconfig attribute is wrong and will follow up on that internally).

These are my test results:

Automatic
OneAgent JavaScript Tag
<script type="text/javascript" src="[...]" data-dtconfig="[...]"></script>
"OneAgent JavaScripTag automatically injected"

CodeSnippet Sync
<script type="text/javascript">[...]</script>
<script type="text/javascript" src="/ajax/ruxitagentjs_A7fhrux_10307250109101944.js"></script>
"CodeSnippetSync automatically injected"

Code Snippet Deferred
<script type="text/javascript">[...]</script>
<script type="text/javascript" src="/ajax/ruxitagentjs_A7fhrux_10307250109101944.js" defer="defer"></script>
"CodeSnippetDeferred automatically injected"

Inlined
<script type="text/javascript" data-dtconfig="[...]">[...]</script>
"InlineCode automatically injected"


Manually
OneAgent JavaScript Tag
<script type="text/javascript" src="[...]" data-dtconfig="[...]" crossorigin="anonymous"></script>
"OneAgent JavaScripTag manually injected"

Codesnippet Sync
<script type="text/javascript">[...]</script>
<script id="dtjsagentdw" type="text/javascript" src="[...]" crossorigin="anonymous"></script>
"CodeSnippetSync manually injected"

Code Snippet Deferred
<script type="text/javascript">[...]</script>
<script src="[...]" defer="defer" id="dtjsagent" crossorigin="anonymous"></script>
"CodeSnippetDeferred manually injected"

Inlined
<script type="text/javascript" data-dtconfig="[...]">[...]</script>
"InlineCode manually injected"

JavaScript Tag
<script type="text/javascript" src="[...]"></script>
"JavaScriptTag manually injected"

 

In my samples dT_.gdi() detected all formats correctly. The thing you mentioned is that dT_.gdi() is searching for "defer", but the only difference is "async", seems to be a misunderstanding though. Internally our config flag is called "async" to tell the JavaScript code to inject the deferred code (this goes back to the time we were still working on appmon).

But this is an internal detail and AFAIK not documented anywhere. The dT_.gdi() function correctly identifies it as deferred snippet though.

I'm happy to have another look, if you provide more information though.

 

Simon

simon_schatka
Dynatrace Advisor
Dynatrace Advisor

And as another remark directly to your questions:

  • dT_.gdi() is mostly developed for support, to find out issues faster and while we have plenty of tests for it, we do not give any guarantees for its functionality. gdi stands for "getDebugInformation" btw. It is not deprecated.
  • Usually customers know the injection format and type. This was added mostly for support purposes to save time when getting an overview about the application. 

Jordi2
Visitor

Hello,

Thank you for your prompt response!

I should have included it in my first post, but here is the result from one of our web applications that leaves me confused:

We have a web application where a CodeSnippetDeferred has been manually injected. The injected code snippet does include the async keyword, which, if I understand correctly from your earlier response, suggests that the code snippet is indeed deferred.

However, when I inspect the web page using DevTools, I notice the following:

<script type="text/javascript"></script>
<script id="dtjsagentdw" type="text/javascript" src="[...]"></script>

I see that the defer="defer" attribute is absent. It is also not present in the snippet provided by the Dynatrace UI when I opt for manual injection of CodeSnippetDeferred for any application.

This has led me to speculate that the dT_.gdi() method may be outputting a manually injected CodeSnippetSync due to the absence of the defer attribute.

Thank you for you assistance,

Jordi

Hi Jordi

Is it possible that you have copied the Deferred Snippet, but have changed the setting in the UI to something else afterwards?
As you may know, one of the big advantages of the dynatrace JavaScript is that we can dynamically update the config. So what I think happens is that the first time you open the page, it is injected deferred. Then we receive a config update from the server side which switches the injection mechanism and therefore your script tag is no longer injected deferred?

You can check the UI to confirm, but you should also be able to confirm by loading your page in Incognito mode (=completely fresh) and check the tag. At this point, the script tag should be injected deferred. After a refresh of the page, the script tag would then be injected without the defer attribute.

Simon

Hello Simon,

The issue did indeed come from the fact that the config is dynamically updated. When opening the web page in incognito mode, the defer tag is present. And when refreshing the page, the defer tag is absent.

Thank you.

Jordi

marco_irmer
Mentor

 There is also a property of applicationType that is tracked within the Dynatrace tenant under the Application (dt.entity.application) entity. This may be useful with a DQL query like the below in a Notebook:

fetch dt.entity.application
| fieldsAdd entity.name, applicationType

 

Featured Posts