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 support for tracking http2 client and server requests #568

Merged
merged 9 commits into from
Jan 24, 2024

Conversation

grcevski
Copy link
Contributor

This PR adds support for tracking http2 client and server requests. Couple of things to note:

  • I had to bump the offsets tracker to minimum of go version 1.18. 1.17 cannot compile the http2 test and we seem to default to latest modules. We may need to fix the offsets tracker instead.
  • No context propagation yet. I need to read few more fields from http2, so once we are OK with the offsets tracker I will follow-up with a PR for this.
  • For the follow-up context propagation we'll get the nextStreamId in (*ClientConn).RoundTrip, just like we do for grpc. Then we'll match it golang.org/x/net/http2.(*Framer).WriteHeaders and append at exit of that function. This is allowed because golang.org/x/net/http2.HeadersFrameParam.PadLength is always 0 and we can extend the buffer with our traceparent header.

@@ -252,7 +252,7 @@ static __always_inline void get_or_create_trace_info(http_connection_metadata_t
#ifdef BPF_TRACEPARENT
// The below buffer scan can be expensive on high volume of requests. We make it optional
// for customers to enable it. Off by default.
if (!capture_header_buffer || !bpf_core_enum_value_exists(enum bpf_func_id, BPF_FUNC_loop)) {
if (!capture_header_buffer) {
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 ifdef around this support, so the runtime check wasn't needed. Plus it was causing compile issues on ARM64 Linux.

@@ -128,12 +128,24 @@ var structMembers = map[string]structInfo{
"nextID": "http2_client_next_id_pos",
},
},
"golang.org/x/net/http2/hpack.Encoder": {
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 noticed that sometimes hpack.Encode doesn't have to be the vendor version in Go. Added it just to be on the safe side.

Copy link
Contributor

@mariomac mariomac left a comment

Choose a reason for hiding this comment

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

LGTM! Once integration tests are fixed, I'm fine with merging.

@@ -1,7 +1,7 @@
{
"go": {
"versions": ">= 1.17",
"inspect": "./configs/offsets/std_inspect.go",
"versions": ">= 1.18",
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder: We will need to document this and state it clearly in the release notes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding the breaking change label, as I understand that we won't support Go 1.17 anymore, right?

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 fixed the go-offsets tracker to support custom files for modules, so we can now bring back Go 1.17, no issues.

@codecov-commenter
Copy link

codecov-commenter commented Jan 24, 2024

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (7c37178) 45.02% compared to head (51bed1d) 44.85%.
Report is 3 commits behind head on main.

Files Patch % Lines
pkg/internal/ebpf/nethttp/nethttp.go 0.00% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #568      +/-   ##
==========================================
- Coverage   45.02%   44.85%   -0.17%     
==========================================
  Files          67       67              
  Lines        5664     5678      +14     
==========================================
- Hits         2550     2547       -3     
- Misses       2964     2981      +17     
  Partials      150      150              
Flag Coverage Δ
unittests 44.85% <0.00%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@grcevski grcevski merged commit 9553916 into grafana:main Jan 24, 2024
4 checks passed
@grcevski grcevski deleted the http2_go branch January 24, 2024 20:58
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