Skip to content

Commit

Permalink
set sentry scopes properly in rake tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Oct 26, 2023
1 parent e4721f0 commit b7bb3a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 8 additions & 4 deletions lib/tasks/mqtt_subscriber.rake
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ namespace :mqtt do
)

client.get do |topic, message|
MqttMessagesHandler.handle_topic(topic, message)
rescue Exception => e
mqtt_log.info e
Sentry.capture_exception(e)
Sentry.with_scope do
begin
MqttMessagesHandler.handle_topic(topic, message)
rescue Exception => e
mqtt_log.info e
Sentry.capture_exception(e)
end
end
end
end
rescue SystemExit, Interrupt, SignalException
Expand Down
12 changes: 7 additions & 5 deletions lib/tasks/telnet.rake
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ namespace :telnet do
p 'Starting Redis subscription...'
Redis.current.subscribe('telnet_queue') do |on|
on.message do |channel, msg|
#puts "#{channel} - #{msg}"
alldata = JSON.parse(msg)
Sentry.with_scope do
#puts "#{channel} - #{msg}"
alldata = JSON.parse(msg)

alldata.each do |data|
telnet_string = "put #{data['name']} #{data['timestamp']} #{data['value']} device_id=#{data['tags']['device_id']} \n"
localhost.print telnet_string
alldata.each do |data|
telnet_string = "put #{data['name']} #{data['timestamp']} #{data['value']} device_id=#{data['tags']['device_id']} \n"
localhost.print telnet_string
end
end
end
end
Expand Down

0 comments on commit b7bb3a5

Please sign in to comment.