feat(playwright): add trace support with opentelemetry #2174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Basic tracing support for Playwright Engine with OpenTelemetry, in a form of a function that is made available to the user through the
test
- the last argument of the user flow function.This function is the tracing equivalent to the
step
function, and is used instead of it in the case where OpenTelemetry reporter is configured for tracing (within thepublish-metrics
plugin).If some of the test scenarios are configured for the
HTTP
engine, they will be traced as normal along with the Playwright scenarios.Should be marked as EXPERIMENTAL!
How
From engine side
beforeScenario
hook function with the following argumentspage
,initialContext
,events
and the User'sprocessor function
.From reporters side:
When tracing is configured, reporter looks for engines used in the script, and if
Playwright
engine is found it creates abeforeScenario
,afterScenario
and thetraceStepFunction
hook.Scenario span is started right before we call the user
flow
function with thebeforeScenario
hookCheck is made to see if tracing is configured, and if it is, we pass this tracing
step
function instead of the regular one to the user.The scenario span is provided as a parent to the step function, so that all the spans user creates are going to be nested inside it.
Once the user function is done we end the scenario span.
The
step
function is responsible for starting and ending a child span with user configured name, optionalattributes
and whatever else the user sets on the span within their processor.It also emits a custom
browser.step.{stepName}
histogram so it can use interchangeably with the non tracingstep
function as proposed in the commentsConfiguration
testScript.yaml
myProcessor.js
Results
The following shows a trace in Honeycomb: