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

Fix net/http instrumentation for register-based ABI #34

Merged
merged 8 commits into from
Mar 27, 2023
Merged

Fix net/http instrumentation for register-based ABI #34

merged 8 commits into from
Mar 27, 2023

Conversation

mariomac
Copy link
Contributor

@mariomac mariomac commented Mar 2, 2023

Makes the stdlib net/http instrumentor to work on register-based ABIs.

Previously, it used the request context pointer as a key for the requests map. With register-based ABI, you can get the arguments in the start uprobe but not in the return uprobes, because the CPU registers might have changed at this point of the execution.

This PR changes the pointer to the context by a pointer to the actual Goroutine that executes the handle, which is guaranteed to be always in the CPU register 14 according to the Go ABI specification.

I have also observed that, at least in recent versions of Go, eBPF probes attached to net/http.(*ServeMux).ServeHTTP are not triggered, so I added a new net/http.HandlerFunc.ServeHTTP function reference and make sure that hooks are added to all the functions.

@edeNFed
Copy link
Contributor

edeNFed commented Mar 9, 2023

lgtm

pkg/instrumentors/bpf/net/http/server/probe.go Outdated Show resolved Hide resolved
pkg/instrumentors/bpf/net/http/server/probe.go Outdated Show resolved Hide resolved
pkg/instrumentors/bpf/net/http/server/probe.go Outdated Show resolved Hide resolved
mariomac and others added 5 commits March 23, 2023 10:52
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
@MrAlias MrAlias merged commit 6afcd71 into open-telemetry:main Mar 27, 2023
@mariomac mariomac deleted the fix-net-http branch March 28, 2023 07:26
@damemi
Copy link
Contributor

damemi commented Mar 31, 2023

@mariomac would this change be relevant to the gorillamux instrumentor too?

JamieDanielson added a commit to honeycombio/opentelemetry-go-instrumentation that referenced this pull request Apr 20, 2023
MrAlias added a commit that referenced this pull request May 12, 2023
* adjust output for e2e test to remove empty span

* only use one http function in http server instr

* Revert "only use one http function in http server instr"

This reverts commit c1bc4d0.

* only use one http function - keep refactor

* keep both func names but only register 1 probe

* mirror changes to gorillamux from server #34

* no more empty spans for gorillamux

* revert http funcname to 1, keep range for register

* make generate

* fix error logger, merge some main changes

* update changelog

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update pkg/instrumentors/bpf/github.com/gorilla/mux/bpf/probe.bpf.c

Co-authored-by: Mike Goldsmith <goldsmith.mike@gmail.com>

* set Method size to 7 in gorillamux probe

* set Method size to 7 in gin-gonic probe

* set Method size to 7 in nethttp probe

* updated traces.json after span name pr merged

* also set method len to 7 in gorillamux probe c

* also set method len to 7 in gin-gonic probe c

* also set method len to 7 in nethttp probe c

* make docker-generate

---------

Co-authored-by: Mike Goldsmith <goldsmith.mike@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
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.

4 participants