From d064addc4082207599eae99e7b8a43d99f4dfa36 Mon Sep 17 00:00:00 2001 From: Tim Cowlishaw Date: Mon, 30 Oct 2023 16:08:07 +0100 Subject: [PATCH] even more sentry instrumentation to track down weird device errors --- app/lib/mqtt_messages_handler.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/lib/mqtt_messages_handler.rb b/app/lib/mqtt_messages_handler.rb index 02cb990f..b972bb4f 100644 --- a/app/lib/mqtt_messages_handler.rb +++ b/app/lib/mqtt_messages_handler.rb @@ -1,9 +1,11 @@ class MqttMessagesHandler def self.handle_topic(topic, message) + Sentry.set_tags('mqtt-topic': topic) + crumb = Sentry::Breadcrumb.new( category: "MqttMessagesHandler.handle_topic", message: "Handling topic #{topic}", - data: { topic: topic, message: message.scrub } + data: { topic: topic, message: message.encode("UTF-8", invalid: :replace, undef: :replace) } ) Sentry.add_breadcrumb(crumb) @@ -33,7 +35,7 @@ def self.handle_topic(topic, message) message: "Parsing info message", data: { topic: topic, - message: message.scrub, + message: message.encode("UTF-8", invalid: :replace, undef: :replace), json: json_message, device_id: device.id } @@ -62,7 +64,7 @@ def self.parse_raw_readings(message, device_id=nil) crumb = Sentry::Breadcrumb.new( category: "MqttMessagesHandler.parse_raw_readings", message: "Parsing raw readings", - data: { message: message.scrub, device_id: device_id } + data: { message: message.encode("UTF-8", invalid: :replace, undef: :replace), device_id: device_id } ) Sentry.add_breadcrumb(crumb) clean_tm = message[1..-2].split(",")[0].gsub("t:", "").strip @@ -79,7 +81,7 @@ def self.parse_raw_readings(message, device_id=nil) crumb = Sentry::Breadcrumb.new( category: "MqttMessagesHandler.parse_raw_readings", message: "Readings data constructed", - data: { message: message.scrub, reading: reading, device_id: device_id } + data: { message: message.encode("UTF-8", invalid: :replace, undef: :replace), reading: reading, device_id: device_id } ) Sentry.add_breadcrumb(crumb)