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):
BrowserTypeBrowserPageFrameElementHandleLocator
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
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mvv_opentelemetry_instrumentation_playwright-0.1.3.tar.gz.
File metadata
- Download URL: mvv_opentelemetry_instrumentation_playwright-0.1.3.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30bc8e5aba3bcbcedd00f8c76b6b920b478783043f14d774e6e46a2c6a502b7d
|
|
| MD5 |
32a956241c833384908ff9cb9dbc8f24
|
|
| BLAKE2b-256 |
ae1b9f5219b49570498a4595a5145130c92462579125a21965223a582c5a9a75
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mvv_opentelemetry_instrumentation_playwright-0.1.3.tar.gz -
Subject digest:
30bc8e5aba3bcbcedd00f8c76b6b920b478783043f14d774e6e46a2c6a502b7d - Sigstore transparency entry: 545446372
- Sigstore integration time:
-
Permalink:
multiversal-ventures/mvv-opentelemetry-instrumentation-playwright@3132c7b646015197fa7c6fd5c750e9b2bf66d017 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/multiversal-ventures
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3132c7b646015197fa7c6fd5c750e9b2bf66d017 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mvv_opentelemetry_instrumentation_playwright-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mvv_opentelemetry_instrumentation_playwright-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c4431a876976af20f9da02dce1e3e21842d49bf657584f4bfe7b9b96502a29d
|
|
| MD5 |
619171064b0389337212936f9e2b049a
|
|
| BLAKE2b-256 |
5d0dc118f14b83a5e57c5d87a6971a25b4bac00206b3ab66f7a8d7ccc089cccc
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mvv_opentelemetry_instrumentation_playwright-0.1.3-py3-none-any.whl -
Subject digest:
8c4431a876976af20f9da02dce1e3e21842d49bf657584f4bfe7b9b96502a29d - Sigstore transparency entry: 545446385
- Sigstore integration time:
-
Permalink:
multiversal-ventures/mvv-opentelemetry-instrumentation-playwright@3132c7b646015197fa7c6fd5c750e9b2bf66d017 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/multiversal-ventures
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3132c7b646015197fa7c6fd5c750e9b2bf66d017 -
Trigger Event:
release
-
Statement type: