Skip to content

Conversation

@slashd0t
Copy link
Contributor

  • added a UnixSocketSender: responsible for sending http request via unix domain socket
  • added ProtobufLogObject: convert the message into Protobuf message

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
Copy link
Contributor

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.

else
Stackify.log_internal_error "Stackify is not properly configured! Errors: #{Stackify.configuration.errors}"
end
when Stackify::UNIX_SOCKET
Copy link
Contributor

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


# 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')
Copy link
Contributor

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.

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."
Copy link
Contributor

Choose a reason for hiding this comment

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

Set this as debug

def send_request msgs
begin
details = Stackify::EnvDetails.instance.set_rails_info
log_group = Stackify::LogGroup.new
Copy link
Contributor

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.

msgs.each do |msg|
log_group.logs << msg
end
log_group.environment = details['ConfiguredEnvironmentName']
Copy link
Contributor

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.

@darinhoward darinhoward merged commit 5566a53 into stackify:master Sep 27, 2019
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.

3 participants