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

Update Flask middleware to not use full URL with query params as a span name #725

Conversation

Kami
Copy link

@Kami Kami commented Jul 23, 2019

This pull request updates Flask middleware so it doesn't use full URL with query params as a spam name.

A lot of times query parameters can contain sensitive data (things such as API keys etc, since not all the services support sending such information via headers so query params are often used as a fallback in such scenarios).

We could perhaps add config option to include query parameters as an attribute with an option for blacklisted attributes (this does increase the complexity of the code and adds additional processing time and overhead to the middleware though).

TODO

  • Tests

@Kami Kami requested review from c24t, reyang, songy23 and a team as code owners July 23, 2019 15:18
Copy link
Contributor

@songy23 songy23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Kami added 2 commits July 23, 2019 18:09
part of the span name.

Including query strings means that the span can potentially contain
sensitive data (a lot of times query params can contain things such as
API keys, etc).
@Kami Kami force-pushed the flask_plugin_dont_include_query_params_in_name branch from 35d1bd8 to 8d94791 Compare July 23, 2019 16:11
@Kami
Copy link
Author

Kami commented Jul 23, 2019

I've added a test case and a changelog entry.

If others think it would be reasonable to add a config option (which defaults to False) which allows query parameters to be stored as a span attribute (with an optional blacklist), I can add that.

Either as part of this PR or as a separate PR once this one is approved and merged.

@Kami Kami force-pushed the flask_plugin_dont_include_query_params_in_name branch from 8d94791 to e383d22 Compare July 23, 2019 16:21
tracer.add_attribute_to_current_span(
HTTP_METHOD, flask.request.method)
tracer.add_attribute_to_current_span(
HTTP_URL, str(flask.request.url))
HTTP_URL, str(flask.request.base_url))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using method + " " + base_url as span name looks good.

Using base_url in HTTP span attribute is against the specification.
I suggest creating a GitHub issue in the spec repo and send PR to update the specification, then implement the spec in Python SDK.

Copy link
Author

@Kami Kami Jul 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will update the code so it will follow the specification.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! FYI we're also open to making the spec better (including privacy & security concerns), any recommendations/ideas are very welcomed.

Copy link
Contributor

@reyang reyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

There is a balance of the data verbosity versus privacy.
The proposed change on HTTP span attribute is against the current specification, need to sort it out in the spec first.

The changes to span name looks fine though. I'd suggest that we proceed with the span change and revert the http.url change for now.

@Kami
Copy link
Author

Kami commented Jul 23, 2019

You are welcome.

Here is the revert - 55447e2.

I will submit feedback against specification. Thanks.

Copy link
Contributor

@reyang reyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @Kami!

@reyang
Copy link
Contributor

reyang commented Jul 23, 2019

I will submit feedback against specification. Thanks.

Great! And @Kami you're very welcomed to help us to design/review the OpenTelemetry APIs. You can read more from https://opentelemetry.io, in a nutshell OpenCensus and OpenTracing are now merging into the same OpenTelemetry project under CNCF, and we'll be porting the majority of extension functionalities to OpenTelemetry.

@reyang
Copy link
Contributor

reyang commented Jul 24, 2019

@Kami please help to rebase, thanks!

@reyang
Copy link
Contributor

reyang commented Aug 6, 2019

This one has been superseded by #746.

@reyang reyang closed this Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants