net/http patch does not return response
zl4bv opened this issue · 4 comments
zl4bv commented
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 commented
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 commented
That's good news! I appreciate you looking into both the issues.
haotianw465 commented
This has been addressed in 0.10.1 release.
zl4bv commented
Thank you so much!