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

feat: k6 gRPC middleware #133

Merged
merged 26 commits into from
Dec 20, 2024
Merged

feat: k6 gRPC middleware #133

merged 26 commits into from
Dec 20, 2024

Conversation

bryanhuhta
Copy link
Contributor

@bryanhuhta bryanhuhta commented Oct 7, 2024

Adds a gRPC variant of the HTTP middleware introduced in this PR: #131

It's important to note that this PR also makes the k6 module independent of the rest of the SDK. I removed it from the root go.work file and create a separate go.work file in the x/k6 directory. I also gave the k6 module its own makefile. This way we can build and test it on the last two versions of Go (and gotip) without imposing that same strict version requirement on the rest of the SDK.

Adding the baggage to the request context makes it easier for users to
pass the baggage along in subsequent requests.
@bryanhuhta bryanhuhta self-assigned this Oct 7, 2024
@bryanhuhta bryanhuhta requested review from a team as code owners October 7, 2024 20:17
Comment on lines +58 to 63
ctx := r.Context()
labels := getBaggageLabelsFromContext(ctx)
if labels == nil {
lh.innerHandler.ServeHTTP(w, r)
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be mistaken (couldn't find a test case), but it seems that baggageToLabels called from getBaggageLabelsFromContext may return a non-nil empty labels (LabelSet), if the baggage only contains non-k6 labels. I would move zero length check to baggageToLabels, so that we do this after filtering, just in case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I'm not sure I completely follow.

You are right that if a baggage header came in but all members were filtered out, we'd end up with a non-nil, empty LabelSet at this point. In which case, we'd fall through and try set labels in the profile context. I fixed that issue in 8477ab7. But I'm not sure I addressed your original concern.

@@ -15,19 +15,32 @@ jobs:
go: ['1.18', '1.19', '1.20', '1.21', '1.22', '1.23', 'tip']
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@marcsanmi marcsanmi Dec 20, 2024

Choose a reason for hiding this comment

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

Nit: could we update the other 2 workflows with checkout@v4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3349e0c

- name: Run go/mod
run: make go/mod && git diff --exit-code

- name: Run k6 go/mod
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also adds extra steps to build and test k6 as an entirely separate module.

@@ -1,5 +1,5 @@
GO_VERSION_PRE20 := $(shell go version | awk '{print $$3}' | awk -F '.' '{print ($$1 == "go1" && int($$2) < 20)}')
TEST_PACKAGES := ./... ./godeltaprof/compat/... ./godeltaprof/... ./x/k6/...
TEST_PACKAGES := ./... ./godeltaprof/compat/... ./godeltaprof/...
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't test the k6 module as part of the main SDK anymore.

@@ -1,8 +1,7 @@
go 1.19
go 1.18
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why we ended up on go1.19 here, but all the submodules are targeting go1.18, so I'm moving the go.work version to match.

x/k6/Makefile Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make targets to build and test the k6 extensions.

Copy link
Contributor

@marcsanmi marcsanmi left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@@ -15,19 +15,32 @@ jobs:
go: ['1.18', '1.19', '1.20', '1.21', '1.22', '1.23', 'tip']
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
Copy link
Contributor

@marcsanmi marcsanmi Dec 20, 2024

Choose a reason for hiding this comment

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

Nit: could we update the other 2 workflows with checkout@v4?

@bryanhuhta bryanhuhta merged commit ecb7b83 into main Dec 20, 2024
8 checks passed
@bryanhuhta bryanhuhta deleted the k6-grpc branch December 20, 2024 22:35
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.

3 participants