Skip to main content
Version: 1.x

Class: OTelReporter

Playwright Reporter that emits OpenTelemetry spans for test lifecycle events.

Example​

const reporter = new OTelReporter({ endpoint: 'http://localhost:4318' });

Implements​

  • Reporter

Constructors​

Constructor​

new OTelReporter(options?): OTelReporter

Parameters​

options?​

OTelReporterOptions = {}

Returns​

OTelReporter

Methods​

onBegin()​

onBegin(_config, _suite): void

Called once before all tests. Initializes the OTel provider.

Parameters​

_config​

FullConfig

Full Playwright config

_suite​

Suite

Root test suite

Returns​

void

Implementation of​

Reporter.onBegin


onEnd()​

onEnd(_result): Promise<void>

Called once after all tests. Shuts down the OTel provider, flushing spans.

Parameters​

_result​

FullResult

The full test run result

Returns​

Promise<void>

Implementation of​

Reporter.onEnd


onStepBegin()​

onStepBegin(test, _result, step): void

Called when a test step begins (hooks, fixtures, user steps, pw:api calls).

Parameters​

test​

TestCase

The parent test case

_result​

TestResult

The test result

step​

TestStep

The step that began

Returns​

void

Implementation of​

Reporter.onStepBegin


onStepEnd()​

onStepEnd(test, _result, step): void

Called when a test step ends.

Parameters​

test​

TestCase

The parent test case

_result​

TestResult

The test result

step​

TestStep

The step that ended

Returns​

void

Implementation of​

Reporter.onStepEnd


onTestBegin()​

onTestBegin(test, _result): void

Called when a test begins execution.

Parameters​

test​

TestCase

The test case

_result​

TestResult

The test result (incomplete at this point)

Returns​

void

Implementation of​

Reporter.onTestBegin


onTestEnd()​

onTestEnd(test, result): void

Called when a test ends. Closes the test-level span.

Parameters​

test​

TestCase

The test case

result​

TestResult

The final test result

Returns​

void

Implementation of​

Reporter.onTestEnd


printsToStdio()​

printsToStdio(): boolean

Whether this reporter prints to stdout. Returns false — OTel uses network export.

Returns​

boolean

Implementation of​

Reporter.printsToStdio