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

contrib/net/http: configurable client ip recording in NewServeMux without environment variable #2342

Open
eyasy1217 opened this issue Nov 11, 2023 · 2 comments
Labels
enhancement quick change/addition that does not need full team approval

Comments

@eyasy1217
Copy link
Contributor

eyasy1217 commented Nov 11, 2023

Hello DataDog Team,

I am currently using the contrib/net/http package from the dd-trace-go library and leveraging the DD_TRACE_CLIENT_IP_ENABLED environment variable to record client IP addresses.

I propose enhancing the NewServeMux function to allow direct configuration for client IP recording, something like:

tracingMux := httptrace.NewServeMux(
    httptrace.EnableClientIP(),
)

I thought this method more intuitive and flexible for setting client IP records.

@eyasy1217 eyasy1217 added the enhancement quick change/addition that does not need full team approval label Nov 11, 2023
@Julio-Guerra
Copy link
Contributor

Hello,

It makes sense indeed.
Would you be up to opening a PR with this addition?

@eyasy1217
Copy link
Contributor Author

👌
But I can only come up with the following ideas😓

  1. Add an EnableClientIP field to http.ServeConfig.

  2. Determine this within http.TraceAndServe and tag the client IP.
    e.g.

var ipTags map[string]string
if cfg.EnableClientIP {
    ipTags, _ = httpsec.ClientIPTags(r.Header, true, r.RemoteAddr)
}
for k, v := range ipTags {
    opts = append(opts, tracer.Tag(k, v))
}

However, the same thing is being done within httptrace.StartRequestSpan😓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement quick change/addition that does not need full team approval
Projects
None yet
Development

No branches or pull requests

2 participants