-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Metrics API #18071
Labels
Comments
/**
* Return a performance metric from the chrome cdp session.
* Note: Chrome-only
* @param {object} page page to attach cdpClient
* @param {String} metricName the name of the metric to be extracted
* @return {Object}
* @see {@link https://github.com/microsoft/playwright/issues/18071 Github RFE}
*/
async function getMetrics(page) {
let client;
client = await page.context().newCDPSession(page);
await client.send('Performance.enable');
const perfMetricObject = await client.send('Performance.getMetrics');
const extractedMetric = perfMetricObject?.metrics;
const metricObject = extractedMetric.reduce((acc, {name, value}) => {
acc[name] = value;
return acc;
}, {});
return metricObject;
} |
good |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Playwright does not currently support a native metrics API made available in puppeteer. https://pptr.dev/api/puppeteer.page.metrics/
This has been filed in a few ways:
#16711 and #590
I believe that #590 best captures the original intent of the RFE and was closed before playwright became widely adopted.
Since 2021, there have been several projects which leverage puppeteer's native metrics API and could/would switch to using playwright-core if the API became native:
nolanlawson/fuite#44
facebook/memlab#35
We are developing our own shim until this API becomes available and would be willing to take on the work on porting this API from puppeteer to playwright if necessary.
The text was updated successfully, but these errors were encountered: