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

Adding match as command line arguement for strict request matching #556

Merged
merged 8 commits into from
Dec 18, 2023
Merged

Conversation

karishma-kasliwal
Copy link
Contributor

@karishma-kasliwal karishma-kasliwal commented Dec 8, 2023

Adding --match where we can pass boolean value for strict request matching while running proxay in 'Replay' mode.
Skipping --match will consider strict matching false, and proxay will behave as before.
Passing --match as true would enable strict request matching, that is zero differences between current request and recorded one.

@CLAassistant
Copy link

CLAassistant commented Dec 8, 2023

CLA assistant check
All committers have signed the CLA.

@timdawborn timdawborn requested review from timdawborn and removed request for flavray December 10, 2023 23:10
@timdawborn
Copy link
Contributor

Hi @karishma-kasliwal, I don't fully understand the purpose of the proposed changes. Could you help me understand what you're trying to achieve here?

Reading the changeset, you're adding a command line argument to be able to change the minimum number of differences needed to consider a tape as matching. The default value for this is +Infinity, meaning that any tape that has any notion of similarity will be considered as a match.

Passing a value of 0 to this argument would mean that proxay would only return tapes with a 100% match (0 differences).

Am I correct that, in practice, no value other than +Infinity and 0 would be provided here? I can't immediately think of any other values that would make sense here. If so, I would suggest that this new CLI argument makes more sense as a flag rather than as a number?

@karishma-kasliwal karishma-kasliwal changed the title Adding score as command line arguement for request matching Adding match as command line arguement for strict request matching Dec 12, 2023
@karishma-kasliwal
Copy link
Contributor Author

Hi @karishma-kasliwal, I don't fully understand the purpose of the proposed changes. Could you help me understand what you're trying to achieve here?

Reading the changeset, you're adding a command line argument to be able to change the minimum number of differences needed to consider a tape as matching. The default value for this is +Infinity, meaning that any tape that has any notion of similarity will be considered as a match.

Passing a value of 0 to this argument would mean that proxay would only return tapes with a 100% match (0 differences).

Am I correct that, in practice, no value other than +Infinity and 0 would be provided here? I can't immediately think of any other values that would make sense here. If so, I would suggest that this new CLI argument makes more sense as a flag rather than as a number?

I have made changes as requested.

Copy link
Contributor

@timdawborn timdawborn left a comment

Choose a reason for hiding this comment

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

LGTM otherwise.

package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "proxay",
"version": "1.6.1",
"version": "1.6.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Issue: Please remove the version bump from this PR. We will do a release later on that contains this changeset as part of the release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

src/cli.ts Outdated
@@ -57,6 +57,7 @@ async function main(argv: string[]) {
.option("--default-tape <tape-name>", "Name of the default tape", "default")
.option("-h, --host <host>", "Host to proxy (not required in replay mode)")
.option("-p, --port <port>", "Local port to serve on", "3000")
.option("--match <match>", "Strict request matching")
Copy link
Contributor

@timdawborn timdawborn Dec 12, 2023

Choose a reason for hiding this comment

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

Suggestion: The CLI argument here could be a lot more self-descriptive:

Suggested change
.option("--match <match>", "Strict request matching")
.option("--exact-request-matching", "Perform exact request matching instead of best-effort request matching during replay.")

Flag CLI arguments don't need a value, it seems: https://github.com/tj/commander.js?tab=readme-ov-file#common-option-types-boolean-and-value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +166 to +168
case "x-datadog-trace-id":
case "x-datadog-parent-id":
case "traceparent":
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking comment: Thanks for these sensible additions 👍

src/cli.ts Outdated
@@ -105,6 +106,7 @@ async function main(argv: string[]) {
const unframeGrpcWebJsonRequestsHostnames: string[] =
options.unframeGrpcWebJsonRequestsHostname;
const rewriteBeforeDiffRules: RewriteRules = options.rewriteBeforeDiff;
const match: boolean = options.match === undefined ? false : options.match;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Rename match to exactRequestMatching throughout this changeset to make the intent of the flag more self-descriptive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@timdawborn timdawborn left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@timdawborn timdawborn left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@timdawborn
Copy link
Contributor

@karishma-kasliwal feel free to merge this PR whenever you're ready. We'll do a release for you once it's merged.

@karishma-kasliwal
Copy link
Contributor Author

karishma-kasliwal commented Dec 18, 2023

elease for you once it's merge

@timdawborn I dont see an option to merge this PR. It could be possible that I dont have the required permissions.
Could you please help me by merging this PR.

@timdawborn timdawborn merged commit dd7751c into airtasker:master Dec 18, 2023
6 checks passed
@timdawborn
Copy link
Contributor

@karishma-kasliwal This functionality has been included in the newly published 1.7.0 release: https://github.com/airtasker/proxay/releases/tag/v1.7.0

Thanks again for contributing!

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.

None yet

3 participants