-
Notifications
You must be signed in to change notification settings - Fork 250
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
Update Flask middleware to not use full URL with query params as a span name #725
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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).
35d1bd8
to
8d94791
Compare
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 Either as part of this PR or as a separate PR once this one is approved and merged. |
8d94791
to
e383d22
Compare
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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
You are welcome. Here is the revert - 55447e2. I will submit feedback against specification. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @Kami!
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. |
@Kami please help to rebase, thanks! |
This one has been superseded by #746. |
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