-
Notifications
You must be signed in to change notification settings - Fork 91
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 HTTP client to not use external memory for header injection #705
Switch HTTP client to not use external memory for header injection #705
Conversation
Nice chnage, I liked the fallback using A couple of questions:
|
So it's called once per client request, but it does get called also when headers are sent in a response of a server request. There will be one extra probe that will run when the application is also a server, but we'll end very quickly since no header will be found, so it's mostly the probe overhead, around 100ns. We can time it with this new tool by Netflix
It's mostly around memory safety, since we'll actually use only memory that the Go garbage collector manages. No rewriting of map spines needs to be done with non-managed memory, which theoretically can cause the GC to temporarily lose reference to the underlying map key values. I've found a way how to do the same for gRPC outgoing calls and HTTP2. My current gRPC implementation is inefficient, but I think I can do the same as for HTTP2 and it will be similar to how we handle HTTP. If we are able to fully work without external memory segments, other things become simpler. OTel Go Auto will be able to run without
I believe we are safe from that scenario, because the code that assumes To validate
In there, they explicitly make a bufio if it wasn't, before the
I believe we are safe, but I can add extra code to confirm the type if you think it's still a problem. |
OK, got it on the performance overhead and Regarding memory safety, I think this is something we need to consider on a per-instrumentation basis. This will tie us to mostly having gRPC/HTTP instrumentations as opposed to achieving full coverage (like otel-go-contrib) |
…lemetry-go-instrumentation into switch_http_header_write
Agreed. As discussed at the SIG, let's try to implement the instrumentations we can without the external memory segment. If the application is only using instrumentations that don't require an external memory segment, we can avoid the ptrace call and the shared memory segment injection. We won't remove the functionality, we'll tag which probes require it and after filtering we can determine if injecting the foreign memory segment is required or not. |
internal/pkg/instrumentation/bpf/net/http/client/bpf/probe.bpf.c
Outdated
Show resolved
Hide resolved
internal/pkg/instrumentation/bpf/net/http/client/bpf/probe.bpf.c
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added two small comments
I'm making a draft pull request for an alternative implementation of header injection, which directly writes in the outgoing request buffer at the beginning when the request headers are serialized. At that point, the outgoing buffer is 4K in size, while typically only handful of bytes are used to write the request method and URL.
This approach has a limitation that the injection will not work if the URL (and the method) are > 4027 bytes and <= 4096 bytes. URLs larger than 2048 are unsupported by various programs, but technically they can be larger. It's possible to overcome this limitation with more work if it's considered a blocker.
TODO: