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

Downstream Http Calls should use hostname rather than full URL as subsegment name #192

Merged
merged 3 commits into from
Dec 6, 2019

Conversation

chanchiem
Copy link
Contributor

Issue #, if available:
#191

Description of changes:
Subsegment names generated by requests, httplib, aiohttp should be the hostname, not the full URL

Added unit tests for requests, httplib, aiohttp to validate this.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…e hostname, not the full URL

Added unit tests for requests, httplib, aiohttp to validate this.
return None
url_parse = urlparse(url)
hostname = url_parse.hostname
return hostname if hostname else url # If hostname is none, we return the regular URL; indication of malformed url
Copy link

@c1tadel c1tadel Dec 5, 2019

Choose a reason for hiding this comment

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

Is this fall-through behavior consistent with other SDKs? If we ask an HTTP client for a URL and get a malformed answer I'm not sure why we'd want to pass it back to the trace -- seems like a repeat of the issue this is intended to solve.

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is in the case where the URL passed in might not necessarily be a parseable URL. Since customers can randomly invoke something like: requests.get("INVALID_DOMAIN_NAME"), we'd still want to be able to capture these types of errors and indicate failure in the subsegment. Otherwise, the subsegment won't be generated at all.

The behavior on our SDKs are mixed; some of them throw NP exceptions because the hostname technically doesn't exist, and therefore doesn't produce anything (which seems like a bug to me).

With that being said, I think doing something similar to Node would be the best of both worlds. Using a known "bad hostname" name, and then still capturing the exception in the subsegment.

@codecov-io
Copy link

codecov-io commented Dec 5, 2019

Codecov Report

Merging #192 into master will increase coverage by 0.07%.
The diff coverage is 95.45%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #192      +/-   ##
=========================================
+ Coverage   83.33%   83.4%   +0.07%     
=========================================
  Files          77      77              
  Lines        2910    2923      +13     
=========================================
+ Hits         2425    2438      +13     
  Misses        485     485
Impacted Files Coverage Δ
aws_xray_sdk/ext/util.py 91.52% <100%> (+2.39%) ⬆️
aws_xray_sdk/ext/aiohttp/client.py 97.5% <100%> (ø) ⬆️
aws_xray_sdk/ext/requests/patch.py 100% <100%> (ø) ⬆️
aws_xray_sdk/ext/httplib/patch.py 75.78% <75%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 324d185...5dbe8b3. Read the comment docs.

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

Successfully merging this pull request may close these issues.

None yet

4 participants