How to get request/response body with uprobe?

62 views Asked by At

https://github.com/open-telemetry/opentelemetry-go-instrumentation internal/pkg/instrumentation/bpf/net/http/server/probe.go

It injects a lot of fields,but Event only contains part of. How can I get response.req from event?

    err = inject.Constants(
        spec,
        inject.WithRegistersABI(target.IsRegistersABI()),
        inject.WithOffset("method_ptr_pos", structfield.NewID("net/http", "Request", "Method"), ver),
        inject.WithOffset("url_ptr_pos", structfield.NewID("net/http", "Request", "URL"), ver),
        inject.WithOffset("ctx_ptr_pos", structfield.NewID("net/http", "Request", "ctx"), ver),
        inject.WithOffset("path_ptr_pos", structfield.NewID("net/url", "URL", "Path"), ver),
        inject.WithOffset("headers_ptr_pos", structfield.NewID("net/http", "Request", "Header"), ver),
        inject.WithOffset("req_ptr_pos", structfield.NewID("net/http", "response", "req"), ver),
        inject.WithOffset("status_code_pos", structfield.NewID("net/http", "response", "status"), ver),
        inject.WithOffset("buckets_ptr_pos", structfield.NewID("runtime", "hmap", "buckets"), ver),
    )
type Event struct {
    context.BaseSpanProperties
    StatusCode uint64
    Method     [8]byte
    Path       [128]byte
}

What if I inject Request.Body like this:

inject.WithOffset("body_ptr_pos", structfield.NewID("net/http", "Request", "Body"), ver)

It's offset is 64, and it's a interface{}, how can I read it from ebpf reader?

0

There are 0 answers