Skip to content
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

feat(playwright): add trace support for playwright with otel reporter #2259

Conversation

InesNi
Copy link
Contributor

@InesNi InesNi commented Oct 27, 2023

Description

What

Tracing support for the Playwright Engine through OpenTelemetry reporter (publish-metrics plugin).

How

Spans

Tracing is implemented in 2 ways:

  • Span is created for each step function call. (The step function is provided inside the test object argument of the processor flow function)
  • Span is created for each framenavigated event where the main frame's page.url() changes, and is active until the next main frame change, portraying the time spent on each page.

Each of these spans is nested within the root scenario span, creating an individual trace per scenario/VU run.

Metrics

  • Web vitals are added as attributes and events on corresponding pageSpan as they happen,
  • When extendedMetrics setting is set to true, other metrics emitted by the engine (dominteractive, browser.memory_used_mb) will be set as attributes as well.
  • VU uuid is set on each span
  • If attributes are set in the OpenTelemetry reporter config, they will be added to all spans.

Errors

In case of an error, spans SpanStatus is set to ERROR and an exception is recorded on the span that contains additional info (e.g. exceptions stack trace)

Configuration

Configuration is the same as for HTTP engine, when tracing is configured inside the OpenTelemetry reporter (within publish-metrics plugin) Playwright scenarios will automatically be traced.

Note

If for some reason the same test is configured with both HTTP and Playwright engine scenarios, they will both be traced, and the same is true for metrics. The configuration provided will be applied to both engines.

Example

Example user processor flow function:

async function testFlow(page, userContext, events, test) {
  await page.goto('https://www.artillery.io/');
  
  await test.step('Go to cloud', async()=>{
      await page
      .getByLabel('Main navigation')
      .getByRole('link', { name: 'Cloud' }).click
  })
  
  await test.step('Click on Join button', async()=>{
    const b = await page
      .getByRole('button', { name: 'Join Artillery Cloud early access waitlist' })
    await b.click()
  })
}

Resulting scenario trace in Honeycomb UI:
Screenshot 2023-10-27 at 19 23 43

Pre-merge checklist

  • Does this require an update to the docs?
  • Does this require a changelog entry?

@InesNi InesNi requested a review from a team October 27, 2023 18:45
@hassy hassy merged commit 6629cb2 into main Nov 15, 2023
6 checks passed
@hassy hassy deleted the ifazlic-art-1373-implement-internal-playwright-tracing-support-with-otel branch November 15, 2023 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants