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 filter out given query parameter in http client? #2732

Open
yulin-li opened this issue Sep 6, 2022 · 5 comments
Open

How to filter out given query parameter in http client? #2732

yulin-li opened this issue Sep 6, 2022 · 5 comments
Labels
area: instrumentation Related to an instrumentation package enhancement New feature or request instrumentation: otelhttp question Further information is requested

Comments

@yulin-li
Copy link

yulin-li commented Sep 6, 2022

In our scenario, some authentication fields are put in the http query parameter. Is there some custom filter I can use to remove these query parameters in the URL when uploading traces?

Thanks.

@yulin-li yulin-li added area: instrumentation Related to an instrumentation package enhancement New feature or request labels Sep 6, 2022
@dmathieu
Copy link
Member

dmathieu commented Sep 6, 2022

The net/http transport injects attributes from the HTTP request here: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/net/http/otelhttp/transport.go#L113
Within this HTTPClientAttributesFromHTTPRequest method, the HTTP URL (which is where I suppose your query string is added) gets appended here: https://github.com/open-telemetry/opentelemetry-go/blob/5568a3072367bb8ac4d2d9e759e7deb5a975b9f5/semconv/internal/http.go#L161

None of those method allow for filtering to skip some of the attributes.
So the only way you can currently do this would be with a custom transport that you run on top of the net/http one provided for tracing, which would modify/nullify the http.url attribute and remove the sensitive data you don't want there.

@yulin-li
Copy link
Author

yulin-li commented Sep 6, 2022

Thanks for the quick response. I will try to build a custom transport for this.

But I think it's a common scenario, would you consider putting this feature request in the backlog?

@dmathieu
Copy link
Member

dmathieu commented Sep 6, 2022

How about an option WithURLSanitizer(func(*net.URL) *net.URL)) which would give you the original URL, and let you do any sanitization you want?

@yulin-li
Copy link
Author

yulin-li commented Sep 6, 2022

That would be great

@dmathieu
Copy link
Member

dmathieu commented Sep 8, 2022

Actually, the approach in open-telemetry/opentelemetry-go#2794 may be better for you.

@MrAlias MrAlias added question Further information is requested instrumentation: otelhttp labels Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: instrumentation Related to an instrumentation package enhancement New feature or request instrumentation: otelhttp question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants