grafana / xk6-browser

k6 extension that adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol
https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/browser/
GNU Affero General Public License v3.0
337 stars 42 forks source link

Metrics aren't being associated with a group #721

Open ankur22 opened 1 year ago

ankur22 commented 1 year ago

Brief summary

While investigating a community support question, I ran into an issue where I noticed that metrics weren't being grouped into groups.

Script:

import { chromium } from 'k6/x/browser';
import { group } from "k6";

export const options = {
  thresholds: {
    'browser_dom_content_loaded{group:::home}': ['p(95)<500'],
    'browser_dom_content_loaded{group:::coinFlip}': ['p(95)<500'],
  },
};

export default async function () {
  const browser = chromium.launch({headless: false});
  const context = browser.newContext();
  const page = context.newPage();
  const page2 = context.newPage();

  try {
    await group('home', async function () {
      await page.goto('https://test.k6.io/')
    })

    await group('coinFlip', async function () {
      await page2.goto('https://test.k6.io/flip_coin.php')
    })
  } finally {
    page.close();
    browser.close();
  }
}

Output:

     browser_dom_content_loaded.......: avg=71.42ms  min=47µs     med=51µs     max=214.18ms p(90)=171.36ms p(95)=192.77ms
     ✓ { group:::coinFlip }...........: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s
     ✓ { group:::home }...............: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s

xk6-browser version

63d5db735ef8770a61aa811e7a698dbadea47793

OS

Mac

Chrome version

Unknown

Docker version and image (if applicable)

NA

Steps to reproduce the problem

Run the given script with the version of xk6-browser (on main).

Expected behaviour

The groups sub-metrics are non zero.

Actual behaviour

The groups sub-metrics are zero.

mstoykov commented 1 year ago

https://github.com/grafana/k6/pull/2863 should fix this

aakash3771 commented 1 year ago

How to get notified when this is fixed?

mstoykov commented 1 year ago

The above PR is unlikely to be merged and it is likely better to follow the underlying problems and possible solutions in https://github.com/grafana/k6/issues/2728