-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Journeys] Set traceparent for Playwright #189800
base: main
Are you sure you want to change the base?
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
This needs elastic/apm-agent-rum-js#1521 to really work - currently the browser transaction becomes the root transaction and the parent of the backend transaction/span, and in the Journey setup, that means that you can no longer navigate the full trace from the perspective of the test runner. |
I have verified elastic/apm-agent-rum-js#1521 works, and the initial page load is associated with the first step from the journey. However, when the page load transaction expires, and new managed transactions are started (e.g. based on an http request or a user interaction event), a new trace ID will be generated, and we can no longer see these events in the trace waterfall. I have reached out to the agent devs to see if there is a solution for that. |
Pushed a change that uses |
@@ -45,7 +45,8 @@ export const getApmConfig = (requestPath: string) => { | |||
...config, | |||
pageLoadTraceId: traceId, | |||
pageLoadSampled: sampled, | |||
pageLoadSpanId: backendTransaction.ensureParentId(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: should we keep this one and use the other ones only as fallbacks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pageLoadSpanId
inverses the relationship - the RUM page-load transaction becomes the parent of the transaction on the backend. I still don't get what the use case is for this (or maybe I forgot), to me it makes more sense to have the server transaction to render the HTML be the parent of the page-load transaction. What are your thoughts here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I'm not familiar with why we did this and what ensureParentId()
does. I'm mostly concerned about breaking the current behavior (I'm not sure if it's already broken 😅).
What you're saying makes a lot of sense to me. However, as I was trying to understand what this parameter does, I found this piece of documentation recommending the use of ensureParentId
as the pageLoadSpanId
on dynamically generated HTML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless anyone is depending on the fact that the RUM transaction is the parent of the backend transaction (I honestly can't think of a use case for this), I think we can safely change this. However, I've reverted this change so we don't have to wait until elastic/apm-agent-rum-js#1521 is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both serve different purpose, For all APM agents (before Synthetics existed) RUM transaction is always considered the root.
- So whenever the HTML is rendered from the Server, the Original Navigation timing span
Requesting and Receiving the document
will include the timing spent on the backend server which captures the time betweenrequestStart
andresponseEnd
. This is the part where thepageLoadSpanId
helps where we can tie the frontend navigation with the backend HTML response generation. - Post Synthetics world, we need a new way to keep the RUM transaction as a child of the Synthetics one since browser is started from the synthetics side (Lots of details are in this issue - [Proposal] Crosslinking Synthetics with APM synthetics#265). This PR feat: add pageLoadParentId configuration apm-agent-rum-js#1521 solves this linking by creating a new option to override the RUM parent trace.
Hope this helps.
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]
History
To update your PR or re-run it, just comment with: |
@@ -15,7 +15,7 @@ export const JOURNEY_APM_CONFIG = { | |||
secretToken: APM_PUBLIC_TOKEN, | |||
active: 'true', | |||
contextPropagationOnly: 'false', | |||
environment: process.env.CI ? 'ci' : 'development', | |||
environment: process.env.ELASTIC_APM_ENVIRONMENT || (process.env.CI ? 'ci' : 'development'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if its required, ENV variables overrides everything by default on the agent level? If this is for RUM agent, then yes its needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's for the RUM agent
return; | ||
} | ||
win.traceIdOverrideListenerAttached = true; | ||
win.elasticApm!.observe('transaction:start', (tx) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a high chance this gets changed before transaction:end
gets fired. Better would be to do it at that time.
💚 Build Succeeded
Metrics [docs]
|
Sets the traceparent for Playwright, so the trace from the test runner includes the trace events from the browser and Kibana server.