lib/nats/rpc/servant.rb in nats-rpc-0.1.0 vs lib/nats/rpc/servant.rb in nats-rpc-0.2.0

- old
+ new

@@ -53,12 +53,19 @@ @count_block_call_errors = @count_block_call_errors + 1 block_call_exception = ex end block_call_stopped_at = Time.now - return @nats.publish reply, error_message(2.0, block_call_exception.message) if block_call_exception + if block_call_exception + err_msg = error_message(2.0, { + message: block_call_exception.message, + backtrace: block_call_exception.backtrace + }) + return @nats.publish reply, err_msg + end + value_as_json = nil begin value_as_json = value.to_json rescue => ex @count_to_json_errors = @count_to_json_errors + 1 @@ -80,11 +87,11 @@ end last_count_messages = 0 loop do throughput = (last_count_messages - @count_messages).abs - debug "s: #{subscribe_to} q: #{opts[:queue]} - msg: #{@count_messages} tput: #{throughput}/s errs json_parse: #{@count_json_parse_errors} block_call: #{@count_block_call_errors} to_json: #{@count_to_json_errors}" + NATS::RPC.stats "s: #{subscribe_to} q: #{opts[:queue]} - msg: #{@count_messages} tput: #{throughput}/s errs json_parse: #{@count_json_parse_errors} block_call: #{@count_block_call_errors} to_json: #{@count_to_json_errors}" last_count_messages = @count_messages sleep 1 end end @@ -95,14 +102,9 @@ status: "error", code: code, payload: data.to_json, servant: @id }.to_json - end - - def debug(str) - return unless ENV["NATS_RPC_DEBUG"] == "true" - puts str end end end end