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

Switch to using per header field parsing for Go versions >= 1.24 #1636

Merged
merged 11 commits into from
Jan 30, 2025

Conversation

grcevski
Copy link
Contributor

@grcevski grcevski commented Jan 16, 2025

This PR is changing how we parse handle the Go HTTP request headers to switch from parsing the Go map to using per header uprobe.

The existing tests should be sufficient to prove this initial version works, since we are already testing for context propagation.

In this first version of the PR I've simply switched how the parsing is done to use the new approach. This approach works regardless of the Go version used, e.g. it will work for Go < 1.24 and Go >= 1.24.

I'm looking for feedback on if we should add a load time constant for the BPF program for the Go version. If we test for the Go version in the BPF code we can choose to use the old approach and not mount the new probe.

There are few pros and cons to each approach:

Proposal 1: We don't read any Go maps until we have swiss maps support

Pros:

  • Simpler to test, since all of our tests will be exercising the same code regardless of the Go version used.
  • Code is much simpler to reason about
  • Go iterates quickly on releases and old versions are quickly dropped out of support

Cons:

  • All go versions instrumentations are slower even for those that we know to read the maps for.

Proposal 2: We use the Go version to turn this on and off

Pros:

  • Older Go version instrumentations will be faster
  • If we ever implement support for swiss maps most of the code will already be there to handle < 1.24 and >= 1.24

Cons:

  • We need to add Go 1.24 release candidate tests to prove this new code works
  • Potential bugs might be version dependent
  • Diminishing returns for the complexity with new Go releases, unless we implement swiss map support quickly.

Consensus:

We chose Proposal 2, where we check for Go version 1.24 to apply the new parsing based approach. I tested manually by modifying the min version in the file to say 1.23.0 and watched the kernel pipe for a specific message to appear that we are using the new approach. The debug message was removed from the final code.

We discussed in the Go Auto SIG the testing story, it seemed acceptable to wait for 1.24 to build the tests and if something doesn't work we'll address it then. I'm going to try to make a test with the pre-release 1.24 and follow up with another PR.

Relates to #1318

@grcevski grcevski requested a review from a team as a code owner January 16, 2025 22:21
@grcevski grcevski changed the title Switch to using per header field parsing Switch to using per header field parsing for Go versions >= 1.24 Jan 26, 2025
@grcevski
Copy link
Contributor Author

@RonFed @MrAlias, do you know why I get this error in my k8s grpc test run?

{"time":"2025-01-26T22:57:39.277971911Z","level":"ERROR","source":{"function":"main.main","file":"/app/cli/main.go","line":125},"msg":"failed to load instrumentation","error":"could not find offset for function net/http.serverHandler.ServeHTTP"}

@grcevski grcevski requested a review from RonFed January 29, 2025 15:57
Copy link
Contributor

@RonFed RonFed left a comment

Choose a reason for hiding this comment

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

Looks awesome, thanks!

Copy link
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

Overall looks good, just comment and doc cleanup. 👍

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
internal/pkg/instrumentation/bpf/net/http/server/probe.go Outdated Show resolved Hide resolved
internal/pkg/instrumentation/probe/probe.go Show resolved Hide resolved
@MrAlias MrAlias merged commit 23291df into open-telemetry:main Jan 30, 2025
28 checks passed
@grcevski grcevski deleted the new_go_hashmap branch January 30, 2025 13:51
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