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

Add conn shutdown error log. Improve other error log messages #33

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -1,3 +1,6 @@
* 4.2.0
- Include URL of server when logging errors
- Add warning log when connection is severed
* 4.1.3
- Bump march_hare version to 2.19.0 to fix reconnection failures with
proxies. See
Expand Down
25 changes: 21 additions & 4 deletions lib/logstash/plugin_mixins/rabbitmq_connection.rb
Expand Up @@ -18,7 +18,7 @@ def self.included(base)
end

def setup_rabbitmq_connection_config
# RabbitMQ server address(es)
# RabbitMQ server address(es)
# host can either be a single host, or a list of hosts
# i.e.
# host => "localhost"
Expand Down Expand Up @@ -201,16 +201,33 @@ def connect

connection = MarchHare.connect(rabbitmq_settings)


connection.on_blocked { @logger.warn("RabbitMQ output blocked! Check your RabbitMQ instance!") }
connection.on_unblocked { @logger.warn("RabbitMQ output unblocked!") }
connection.on_shutdown do |conn, cause|
@logger.warn("RabbitMQ connection was closed!",
:url => connection_url(conn),
:automatic_recovery => @automatic_recovery,
:cause => cause)
end
connection.on_blocked do
@logger.warn("RabbitMQ connection blocked! Check your RabbitMQ instance!",
:url => connection_url(connection))
Copy link
Contributor

Choose a reason for hiding this comment

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

are we sure this (connection) does not log any auth information?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see masking is done below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

end
connection.on_unblocked do
@logger.warn("RabbitMQ connection unblocked!", :url => connection_url(connection))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make this info?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been warn for a long time. I think it is something that is warning level, normally queues should not be blocked unless there's a problem.

end

channel = connection.create_channel
@logger.info("Connected to RabbitMQ at #{rabbitmq_settings[:host]}")

HareInfo.new(connection, channel)
end

# Mostly used for printing debug logs
def connection_url(connection)
user_pass = connection.user ? "#{connection.user}:XXXXXX@" : ""
protocol = params["ssl"] ? "amqps" : "amqp"
"#{protocol}://#{user_pass}#{connection.host}:#{connection.port}#{connection.vhost}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see this here. Ignore my comment above

end

def sleep_for_retry
Stud.stoppable_sleep(@connect_retry_interval) { @rabbitmq_connection_stopping }
end
Expand Down
2 changes: 1 addition & 1 deletion logstash-mixin-rabbitmq_connection.gemspec
@@ -1,7 +1,7 @@

Gem::Specification.new do |s|
s.name = 'logstash-mixin-rabbitmq_connection'
s.version = '4.1.3'
s.version = '4.2.0'
s.licenses = ['Apache License (2.0)']
s.summary = "Common functionality for RabbitMQ plugins"
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
Expand Down
1 change: 1 addition & 0 deletions spec/plugin_mixins/rabbitmq_connection_spec.rb
Expand Up @@ -96,6 +96,7 @@ def register
allow(connection).to receive(:create_channel).and_return(channel)
allow(connection).to receive(:on_blocked)
allow(connection).to receive(:on_unblocked)
allow(connection).to receive(:on_shutdown)

instance.register
end
Expand Down