browser-sdk
browser-sdk copied to clipboard
💡 RUM<>APM link for the initial document
Hello 👋
I have a question about RUM and Traces connection.
The current workflow we have:
- Browser requests initial page , e.g.
/
- Server handles the request:
a. makes requests to other backend services (with integrated APM)
b. renders a requested page with data and injects
DD_RUM
init script c. responds to browser with the page markup - Browser renders the page and initialise DD_RUM
This works well - all the further the requests from browser are connected with the APM traces.
But the problem with the initial request to /
.
Yes, the documentation says:
End-to-end tracing is available for requests fired after the Browser SDK is initialized. End-to-end tracing of the initial HTML document and early browser requests is not supported.
At the same time it would be very valuable to have this feature available.
Let's say, during SSR (point 2a
) the server could inject some id (e.g. the active span from dd-trace
) into the initial DD_RUM
config, that would be handled in the user session (point 3
). As result, the initial page request could be connected to all the related APM traces.
Do you have any plans to support this feature?
Hi @mrkosima
This is a topic we already explored in the past. We even have some code for just this in the SDK. Sadly we did not finish the project just yet as we did not manage to do the change in the Datadog Agent to automatically add the trace id in the initial document.
For now, you might want to try setting <meta>
tags as such:
<meta name="dd-trace-id" content="123" />
<meta name="dd-trace-time" content="456" />
where dd-trace-id
is the trace id used to render the document and dd-trace-time
is a unix timestamp in milliseconds representing the date when the document was rendered (we use it to mitigate cached documents).
The SDK will pick up the trace id and associate it with the document
resource, so you'll be able to see the associated trace in the Datadog App.
Keep in mind that this is still experimental and might be removed in the future.
Any updates?