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.3.tar.gz.

File metadata

File hashes

Hashes for mvv_opentelemetry_instrumentation_playwright-0.1.3.tar.gz
Algorithm Hash digest
SHA256 30bc8e5aba3bcbcedd00f8c76b6b920b478783043f14d774e6e46a2c6a502b7d
MD5 32a956241c833384908ff9cb9dbc8f24
BLAKE2b-256 ae1b9f5219b49570498a4595a5145130c92462579125a21965223a582c5a9a75

See more details on using hashes here.

Provenance

The following attestation bundles were made for mvv_opentelemetry_instrumentation_playwright-0.1.3.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.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mvv_opentelemetry_instrumentation_playwright-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8c4431a876976af20f9da02dce1e3e21842d49bf657584f4bfe7b9b96502a29d
MD5 619171064b0389337212936f9e2b049a
BLAKE2b-256 5d0dc118f14b83a5e57c5d87a6971a25b4bac00206b3ab66f7a8d7ccc089cccc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mvv_opentelemetry_instrumentation_playwright-0.1.3-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