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

How to add request-id/trace-id to http request header? #37

Open
yfractal opened this issue Oct 20, 2022 · 5 comments
Open

How to add request-id/trace-id to http request header? #37

yfractal opened this issue Oct 20, 2022 · 5 comments

Comments

@yfractal
Copy link

Feature request

Allow opentelemetry-go-instrumentation trace http requests.

How to implement?

A Golang project may send http request to other servers through Golang net/request, for doing distributed tracing need to add the trace id in http headers.

The header is a map https://cs.opensource.google/go/go/+/refs/tags/go1.19.2:src/net/http/request.go;l=148.

If we do this through uprobe, we need edit a Golang map.

So how could we do this? Or do we have other options?

I guess eBPF program can't call a user's function easily, so we have to mange the memory, but map is complex, not sure how to do this.

Maybe we can calculate where we can put the key/value pair(we know the key and can know the length of value), and use the result to do memory management?

@edeNFed
Copy link
Contributor

edeNFed commented Oct 20, 2022

Hi @yfractal
You are right, appending to map is more complex than appending to slice and is not a logic we implemented yet.
Until we implement the map operations the way we do it today is by appending to the slice created in the function that iterates over the map. In an HTTP client example a good candidate would be: https://cs.opensource.google/go/go/+/master:src/net/http/header.go;l=173

Both of these tasks (HTTP client support + appending to maps) are on our roadmap and will be implemented in future versions. If you would like to help, we will be happy to accept a PR 😄

@yfractal
Copy link
Author

Thanks edeNFed, I will try to figure how to do this, but I'm not sure when I can achieve this, I'm short of knowledge both C, eBPF and golang 😂

@edeNFed
Copy link
Contributor

edeNFed commented Oct 23, 2022

No worries, this will be added very soon

@yfractal
Copy link
Author

Really great, thanks edeNFed!

@liyan-ah
Copy link

liyan-ah commented Mar 1, 2023

looking forward!

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

No branches or pull requests

3 participants