Skip to content

Instantly share code, notes, and snippets.

@blasterpal
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save blasterpal/ad1cd2a4788a96f8c929 to your computer and use it in GitHub Desktop.

Select an option

Save blasterpal/ad1cd2a4788a96f8c929 to your computer and use it in GitHub Desktop.
querying bugsnag for data
# https://github.com/bugsnag/bugsnag-api-ruby
require 'bugsnag/api'
Bugsnag::Api.configure do |config|
config.auth_token = "your-account-api-token"
end
errors = Bugsnag::Api.errors(web_project_id)
error = Bugsnag::Api.error(error_id)
events = Bugsnag::Api.error_events error_id
custom_data_events = events.map {|ea| ea[:meta_data][:Custom] }
explained = custom_data_events.select { |ea| !ea[:explain].empty? }
not_explained = custom_data_events.select { |ea| !ea[:explain].empty? }
# get ALL prod events for an error:
events = Bugsnag::Api.error_events error_id;nil
prod_events = events.select {|e| e[:meta_data][:App][:releaseStage] == "production" };nil
while (next_page = Bugsnag::Api.last_response.rels[:next].get.data) do
putc '.'
prod_events.concat (next_page.select {|e| e[:meta_data][:App][:releaseStage] == "production" } )
end
#get unique/subset list of worker/exceptions
job_uniq_classes = Set.new
subset = some_events.select do |ea|
custom = ea[:meta_data][:Custom]
explain = custom[:explain]
job_info = custom[:job_info]
if job_info && explain
job_class = job_info.first
if job_uniq_classes.include?(job_class)
false
else
job_uniq_classes.add(job_class)
true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment