-
Notifications
You must be signed in to change notification settings - Fork 12
RT 3680 Add socket transport to Ruby Logging API #26
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
Conversation
slashd0t
commented
Sep 25, 2019
- added a UnixSocketSender: responsible for sending http request via unix domain socket
- added ProtobufLogObject: convert the message into Protobuf message
lib/stackify/logger_client.rb
Outdated
| def log_exception level= :error, ex | ||
| if ex.is_a?(Stackify::StackifiedError) | ||
| Stackify::Utils.do_only_if_authorized_and_mode_is_on Stackify::MODES[:logging] do | ||
| case Stackify.configuration.transport |
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.
Suggest changing the structure of the logger-client to have an interface an multiple implementations - one for api communication and one for unix domain socket. This will avoid duplication of logic in each 'when' clause.
lib/stackify-api-ruby.rb
Outdated
| else | ||
| Stackify.log_internal_error "Stackify is not properly configured! Errors: #{Stackify.configuration.errors}" | ||
| end | ||
| when Stackify::UNIX_SOCKET |
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.
configuration for unix domain socket currently only affects the logging portion. The library should continue to support metrics being uploaded via the api even if the unix domain socket is setup for logging
lib/stackify/unix_socket_sender.rb
Outdated
|
|
||
| # Convert data into binary and send it to unix domain socket | ||
| message = Stackify::LogGroup.encode(log_group) | ||
| client = NetX::HTTPUnix.new('unix:///usr/local/stackify/stackify.sock') |
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.
set socket path as a variable - no need for configuration override yet.
lib/stackify/unix_socket_sender.rb
Outdated
| req.body = message | ||
| response = client.request(req) | ||
| if response.code.to_i == 200 | ||
| Stackify.internal_log :info, "[UnixSocketSender]: Successfully send message via unix domain socket." |
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.
Set this as debug
lib/stackify/unix_socket_sender.rb
Outdated
| def send_request msgs | ||
| begin | ||
| details = Stackify::EnvDetails.instance.set_rails_info | ||
| log_group = Stackify::LogGroup.new |
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.
suggest refactoring to have the log_group creation outside of the send_requests function.
lib/stackify/unix_socket_sender.rb
Outdated
| msgs.each do |msg| | ||
| log_group.logs << msg | ||
| end | ||
| log_group.environment = details['ConfiguredEnvironmentName'] |
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.
is this section similar to the gather_and_pack_data function in logs_sender.rb? I noticed that some of the details referenced were different.
…side the send_request()
…setup() configuration