From d8dc0fd9b578bab4f8c11e3a434976bcd2c9971e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Codru=C8=9B=20Constantin=20Gu=C8=99oi?= Date: Wed, 19 Feb 2020 13:20:49 +0000 Subject: [PATCH 1/2] Fix running on older ruby versions: filter is an alias of select --- lib/hutch/broker.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hutch/broker.rb b/lib/hutch/broker.rb index 010899e6..0ef86646 100644 --- a/lib/hutch/broker.rb +++ b/lib/hutch/broker.rb @@ -184,7 +184,7 @@ def bindings filtered = api_client.bindings. reject { |b| b['destination'] == b['routing_key'] }. - filter { |b| b['source'] == @config[:mq_exchange] && b['vhost'] == @config[:mq_vhost] } + select { |b| b['source'] == @config[:mq_exchange] && b['vhost'] == @config[:mq_vhost] } filtered.each do |binding| results[binding['destination']] << binding['routing_key'] @@ -197,7 +197,7 @@ def bindings def unbind_redundant_bindings(queue, routing_keys) return unless http_api_use_enabled? - filtered = bindings.filter { |dest, keys| dest == queue.name } + filtered = bindings.select { |dest, keys| dest == queue.name } filtered.each do |dest, keys| keys.reject { |key| routing_keys.include?(key) }.each do |key| logger.debug "removing redundant binding #{queue.name} <--> #{key}" From 0ca9ffd90eb33f076082d708c32a6270d07c8f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Codru=C8=9B=20Constantin=20Gu=C8=99oi?= Date: Wed, 19 Feb 2020 11:55:35 +0000 Subject: [PATCH 2/2] Better log levels in the message publisher Having the entire payload logged at the "INFO" level is not ideal due to the following reasons: - PII data might be contained there and there is no way to fitler it out - Payload might be big enough that logging aggregators might struggle with the sheer amount of data - Since the log level is shared by reusing the rails/sinatra logger, INFO level might be too verbose for hutch but WARN level not verbose enough for the other. While initially I considered implementing a feature to allow for filtering the payload for PII or triming the output, a quick solution to all problems listed above is to change the logging statement to DEBUG, which should only be needed in development/testing environments. --- lib/hutch/publisher.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hutch/publisher.rb b/lib/hutch/publisher.rb index 80588492..675da1de 100644 --- a/lib/hutch/publisher.rb +++ b/lib/hutch/publisher.rb @@ -42,7 +42,7 @@ def publish(routing_key, message, properties = {}, options = {}) private def log_publication(serializer, payload, routing_key) - logger.info { + logger.debug { spec = if serializer.binary? "#{payload.bytesize} bytes message"