bugsnag / bugsnag-api-ruby

BugSnag API toolkit for Ruby
Other
21 stars 15 forks source link

Multiple issues #18

Closed mickey closed 4 years ago

mickey commented 6 years ago

Hey there, I'm trying to work with you API and encountered a few issues. I'm using the last gem version (2.0.2).

1/ Trying to use custom pagination. So I copy-pasted your documentation example:

errors = ::Bugsnag::Api.errors("XXXX", per_page: 100)
puts errors.count # 30 

The per_page does not work.

2/ Then I tried to use the auto_paginate and the per_page option:

Bugsnag::Api.configure do |config|
  config.auth_token = ENV["BUGSNAG_AUTH_TOKEN"]
  config.auto_paginate = true
  config.per_page = 100
end

And first the offset is wrong :(

D, [2018-03-29T16:54:43.424072 #24655] DEBUG -- : [httplog] GET http://api.bugsnag.com:443/projects/XXXX/errors?per_page=100 completed with status code 200 in 0.7256659999993644 seconds
D, [2018-03-29T16:54:44.188476 #24655] DEBUG -- : [httplog] GET http://api.bugsnag.com:443/projects/XXXX/errors?base=2018-03-29T14%3A54%3A43Z&offset=30&per_page=100 completed with status code 200 in 0.7253240000000005 seconds
D, [2018-03-29T16:54:45.110955 #24655] DEBUG -- : [httplog] GET http://api.bugsnag.com:443/projects/XXXX/errors?base=2018-03-29T14%3A54%3A43Z&offset=60&per_page=100 completed with status code 200 in 0.8854650000002948 seconds

Offset is by 30 instead of 100. And secondly it doesn't handle throttling (I always end up with 429).

Also what's up with the throttling? I'm on a paid-plan and throttled after a few requests only :(

3/ I tried to use the filters option but no matter what I try it never works, here's an example:

::Bugsnag::Api.errors("XXX", filters: {"error.status": [{ "type": "eq", "value": "open" }]}).map {|e| e.status }
# D, [2018-03-29T17:04:42.157535 #25060] DEBUG -- : [httplog] GET http://api.bugsnag.com:443/projects/5326af10bbddbdd9210000cf/errors completed with status code 200 in 0.7052990000001955 seconds
# => ["open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "snoozed", "snoozed", "snoozed", "open", "open", "snoozed", "open", "snoozed", "snoozed", "snoozed", "snoozed", "open", "open", "open", "ignored", "snoozed", "open"]

Is this gem still maintained or am I doing something terribly wrong?

Cawllec commented 6 years ago

Hi @mickey, thanks for the update. This gem is maintained and should be working as stated.

We'll check issues related to pagination and filtering and get them fixed as soon as possible.

mickey commented 6 years ago

Thanks a lot for the follow-up!

Cawllec commented 6 years ago

So the filters issue may be that you're missing an argument from the errors method. I'm going to submit a PR for making the errors and error functions easier to use, but in the meantime could you try again with: ::Bugsnag::Api.errors("XXX", nil, filters: {"error.status": [{ "type": "eq", "value": "open" }]}).map {|e| e.status }?

mickey commented 6 years ago

Thanks for following-up!

For the filters issue, I tried again and it works fine with the added argument:

::Bugsnag::Api.errors("XXX", nil, filters: {"error.status": [{ "type": "eq", "value": "open" }]}).map {|e| e.status }
=> ["open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open", "open"]

I'm going to submit a PR for making the errors and error functions easier to use

👍 Also a few examples in the documentation would be great

abigailbramble commented 4 years ago

@mickey - Looks like this has since been fixed in the dashboard. If you have further questions or comments, let us know!