-
Notifications
You must be signed in to change notification settings - Fork 13
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
Allow to set custom logger #9
Conversation
lib/zipkin/json_client.rb
Outdated
@@ -38,11 +39,11 @@ def emit_batch(spans) | |||
request.body = JSON.dump(spans) | |||
response = http.request(request) | |||
|
|||
if response.code != 202 | |||
STDERR.puts(response.body) | |||
if response.code.to_s != '202' |
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.
why are we convering response code to string?
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.
Response code is a string in my environment, not sure about the other, so decided to convert it to string before checking.
This was the reason of random new line characters in logs, because the gem logged empty body on successful responses.
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.
http://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTPResponse.html
The HTTP result code string. For example, ‘302’. You can also determine the response type by examining which response subclass the response object is an instance of.
Looks like you're right. Can you please remove #to_s
from response.code but lets keep 202 as a string.
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.
https://ruby-doc.org/stdlib-2.5.0/libdoc/net/http/rdoc/Net/HTTPResponse.html
The HTTP result code string. For example, '302'. You can also determine the response type by examining which response subclass the response object is an instance of.
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.
By the way, I've also seen these blank lines, but didn't have time to look much into it. Thanks for the fix.
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.
Removed it.
Thank you! |
Use logger to log errors and allow to set a custom logger. Also, fixes a bug that resulted in writing new line characters to stdout on successful responses from zipkin.