Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set sentry scopes properly in rake tasks #270

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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