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

Feature Request: Add support for filtering span attributes in net/http package #837

Open
BlakeWilliams opened this issue Jun 29, 2021 · 4 comments
Labels

Comments

@BlakeWilliams
Copy link

We're writing an application and would like the ability to filter the http.url attribute that is automatically set in spans. It's possible the url can contain secrets or other information that we would like to avoid sending to third parties.

I'd be happy to spend time getting this working and open a PR if there's interest in adding this functionality to the net/http package.

Definitely open to thoughts on what the API should look like, but maybe it could be an option on the config struct?

I'm imagining something roughly like:

transport := otelhttp.NewTransport(http.DefaultTransport, WithSpanAttributeFilter(attributeFilter))

func attributeFilter(kv attribute.KeyValue, r *http.Request) bool {
    return false;
}
@Aneurysm9
Copy link
Member

Would this be better as a SpanProcessor on the TracerProvider? That would give it access to all spans, not just the ones created by this instrumentation. Not necessarily opposed to the idea, just wondering if there is a higher-leverage implementation point.

@BlakeWilliams
Copy link
Author

@Aneurysm9 That's a good question. I took a look at using SpanProcessor but couldn't see how it could be composed with the batchSpanProcessor that we're currently using.

@Aneurysm9
Copy link
Member

Here is an example showing a filter setup. The BSP would be provided to the filter processor as a next step. I'm not sure it would work for this use, though, since OnEnd receives a ReadOnlySpan. It could filter out spans entirely, but not remove certain attributes without some gymnastics to reconstruct a writable span.

@BlakeWilliams
Copy link
Author

I'm not sure it would work for this use, though, since OnEnd receives a ReadOnlySpan. It could filter out spans entirely, but not remove certain attributes without some gymnastics to reconstruct a writable span.

Yeah, that's what I was thinking as well. I don't want to filter out the entire span, just some of the attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants