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

net/http patch does not return response #2

Closed
zl4bv opened this issue Feb 20, 2018 · 4 comments
Closed

net/http patch does not return response #2

zl4bv opened this issue Feb 20, 2018 · 4 comments
Labels

Comments

@zl4bv
Copy link

zl4bv commented Feb 20, 2018

I'm trying to use the X-Ray SDK with the patch enabled for net/http, but instead of returning an HTTPResponse object it looks like it's returning an HTTP status code as an Integer.

Here's a snippet with the unpatched net/http library:

require 'net/http'

http = Net::HTTP.new('aws.amazon.com', 80)
req = Net::HTTP::Get.new('/')
res = http.request(req)
puts res.body

Here's what is printed when running the snippet:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://aws.amazon.com/">here</a>.</p>
</body></html>

Here's a snippet with the patched net/http library:

require 'net/http'
require 'aws-xray-sdk'
require 'aws-xray-sdk/facets/net_http'

XRay.recorder.configure({patch: %I[net_http]})
XRay.recorder.begin_segment 'my_service'

http = Net::HTTP.new('aws.amazon.com', 80)
req = Net::HTTP::Get.new('/')
res = http.request(req)
puts res.body

XRay.recorder.end_segment

Here's what is printed when running the snippet:

Traceback (most recent call last):
/Users/ben.vidulich/Desktop/snippet2.rb:11:in `<main>': undefined method `body' for 301:Integer (NoMethodError)
@haotianw465
Copy link
Contributor

Theere is one line missing which should return the value of calling super: https://github.com/aws/aws-xray-sdk-ruby/blob/master/lib/aws-xray-sdk/facets/net_http.rb#L46

Will release a fix soon.

@zl4bv
Copy link
Author

zl4bv commented Feb 20, 2018

That's good news! I appreciate you looking into both the issues.

@haotianw465
Copy link
Contributor

This has been addressed in 0.10.1 release.

@zl4bv
Copy link
Author

zl4bv commented Feb 22, 2018

Thank you so much!

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

2 participants