Skip to main content

Automatic tracing and metrics for your Playwright browser automation scripts using OpenTelemetry.

Project description

OpenTelemetry Instrumentation for Playwright

Automatic tracing and metrics for your Playwright browser automation scripts using OpenTelemetry.

This package supports both synchronous and asynchronous Playwright APIs, enabling deep observability into your browser automation and testing workflows.

Features

  • Automatic tracing of Playwright browser, page, and element actions
  • Supports both sync and async Playwright APIs
  • Rich span attributes for method arguments and context
  • Easy integration with OpenTelemetry SDKs and exporters
  • Customizable tracer and meter providers

Getting Started

First, add the mvv-opentelemetry-instrumentation-playwright package as a dependency.

uv add mvv-opentelemetry-instrumentation-playwright

If you haven't already, make sure Playwright is set up:

uv run playwright install --with-deps

Then, instrument your application:

from opentelemetry.instrumentation.playwright import PlaywrightInstrumentor
import playwright.sync_api

# Instrument Playwright
PlaywrightInstrumentor().instrument()

with playwright.sync_api.sync_playwright() as p:
    with p.chromium.launch(headless=True) as browser:
        with browser.new_page(user_agent="test", is_mobile=False) as page:
            title = page.title()
            print("Page title:", title)

This will emit spans like the following:

├── playwright.sync_api._generated.BrowserType:launch {headless: true}
├── playwright.sync_api._generated.Browser:__enter__
|   ├── playwright.sync_api._generated.Browser:new_page {user_agent: "test", is_mobile: false}
|   ├── playwright.sync_api._generated.Page:__enter__
|   |   └── playwright.sync_api._generated.Page:title
|   └── playwright.sync_api._generated.Page:close
└── playwright.sync_api._generated.Browser:close

You can pass a custom tracer or meter provider:

from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.instrumentation.playwright import PlaywrightInstrumentor

provider = TracerProvider()
PlaywrightInstrumentor().instrument(tracer_provider=provider)

To uninstrument (remove all patches):

from opentelemetry.instrumentation.playwright import PlaywrightInstrumentor

instrumentor = PlaywrightInstrumentor()
instrumentor.instrument()

# ...

instrumentor.uninstrument()

Supported Playwright APIs

This package instruments a wide range of methods from the following Playwright classes (sync and async):

  • BrowserType
  • Browser
  • Page
  • Frame
  • ElementHandle
  • Locator

Common actions like launch, new_page, goto, click, type, screenshot, and many more are traced with relevant attributes.

See the targets.py file for a full list of the methods that are instrumented, along with the parameters that will be attached to the Open Telemetry span as parameters.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file mvv_opentelemetry_instrumentation_playwright-0.1.2.tar.gz.

File metadata

File hashes

Hashes for mvv_opentelemetry_instrumentation_playwright-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4687b632c4e6b83bdb9ba7e435eeec79f18321867ca0da3411ba41c58d4a6650
MD5 81183d30992ea7ce1508b9f8ed35175d
BLAKE2b-256 6a739f4ac5c63d44aada79854ffaaaa5b8a1a8edfcd4174eb08197f30a0e52af

See more details on using hashes here.

Provenance

The following attestation bundles were made for mvv_opentelemetry_instrumentation_playwright-0.1.2.tar.gz:

Publisher: publish.yml on multiversal-ventures/mvv-opentelemetry-instrumentation-playwright

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mvv_opentelemetry_instrumentation_playwright-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mvv_opentelemetry_instrumentation_playwright-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d342a4932daf55c61bd81b197b436a15ed3b95b81143781578e4a682a45c8041
MD5 1561fed7102f75676c13bd35ee7f512a
BLAKE2b-256 b26c135e4e377ac29c3b796f30a57d86fdf8ece117c43824722a45ca9cd1822e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mvv_opentelemetry_instrumentation_playwright-0.1.2-py3-none-any.whl:

Publisher: publish.yml on multiversal-ventures/mvv-opentelemetry-instrumentation-playwright

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page