grafana/xk6-browser

Filter out request metrics by their URL tag

Opened this issue · 2 comments

Feature Description

As mentioned in #371, there could be a need to filter out metrics from requests with given urls which just create noise in the results. These could be requests that track user flow, adverts, or requests which aren't related to your team's ownership (if a website/page is split between multiple teams). These wouldn't be useful to see in the results and instead create noise.

Suggested Solution (optional)

  1. Implement page.route (#10), to allow the user to add urls to intercept and abort, thus not recording metrics to do with that request. This would also prevent the request from being sent.
  2. Extend the functionality in page.on('metric') to allow for an ignore function, so that users can ignore metrics but still allow the request to complete e.g.:
    • page.on('metric', metric => {
         // All metrics will not be recorded if the url tag matches the regex.
         metric.ignoreURLTag({
         urls: [
           {url: /^https:\/\/example\.com\/[0-9a-f]*\/checkout\/[0-9a-f]*$/},
           {url: /^https:\/\/example\.com\/catalogue\?session=[0-9a-f]*$/},
         ]});
      });

Other considerations

We should use the feature to ignore about:blank metrics!

Already existing or connected issues / PRs (optional)

Compliments #371
Connected: #10

Can we filter out about:blank metrics by default once this is in place?

Can we filter out #518 by default once this is in place?

Nice idea! Yes, we should do that 👍