Skip to content

Commit

Permalink
even more sentry instrumentation to track down weird device errors
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Oct 30, 2023
1 parent 871c969 commit d064add
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/lib/mqtt_messages_handler.rb
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit d064add

Please sign in to comment.