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.

You can find the full list of methods that are instrumented with the annotated_methods() function from the opentelemetry.instrumentation.playwright.targets module.

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

File metadata

File hashes

Hashes for mvv_opentelemetry_instrumentation_playwright-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1fe42bf4838ba6b6383b5941d76ad2e2b58e8a8fddbffe471f042c29f585b3ae
MD5 b69c4ac9d97ce848557422d96fd67028
BLAKE2b-256 3ff4c45efa72e90b5585b58edc24cb59273b9b724c327c48d9c933621069ce45

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mvv_opentelemetry_instrumentation_playwright-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f0dd4e462f9e924224b302ad4655496e206ebff26f821251fbc8040004879548
MD5 bbee0fae62dd8b58154f660891e52102
BLAKE2b-256 617dea57b82548baa08d11c1836f75c1c31dc47dc70c7f99da767a65b76ebca0

See more details on using hashes here.

Provenance

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