Skip to content
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

Add method field on Match object for page.on('metric') #1490

Merged
merged 12 commits into from
Oct 17, 2024

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented Oct 17, 2024

What?

This change adds a new field to the Match object in page.on('metric'). It allows the user to add the request method to it so that the tagging can be fine tuned to group requests with the same url and method. method is an optional field, and if it's not defined then the grouping will be done for all urls that match regardless of the request method.

page.on('metric', (metric) => {
  metric.tag({
    name:'ping-1',
    matches: [
      {url: /^http:\/\/127\.0\.0\.1\:[0-9]+\/ping\?h=[0-9a-z]+$/, method: 'GET'},
    ]
  });
});

Why?

The use case for this is when requests are made against the same URL but with different request methods. A simple example is a PUT to /cart/123 to add an item to the cart, and a GET to /cart/123 to retrieve the cart.

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

Related PR(s)/Issue(s)

Updates: #1450

@ankur22 ankur22 force-pushed the add/method-page-on-metric branch from 9ef4b50 to a6b12e9 Compare October 17, 2024 15:02
@ankur22 ankur22 requested a review from inancgumus October 17, 2024 15:06
@ankur22 ankur22 changed the title Add method on page.on('metric') Add method field on Match object for page.on('metric') Oct 17, 2024
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

common/page.go Show resolved Hide resolved
@ankur22 ankur22 merged commit aedd78e into main Oct 17, 2024
23 checks passed
@ankur22 ankur22 deleted the add/method-page-on-metric branch October 17, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants