Skip to content

Commit

Permalink
Merge pull request ono#3 from Fullscript/add-sentry-link
Browse files Browse the repository at this point in the history
Add link to open the corresponding Sentry events
  • Loading branch information
andrewmarkle authored Mar 7, 2024
2 parents a2ae131 + ac22888 commit e0ac43e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.0 (2024-03-04)

* Add link to Sentry issues in the event list view based on the current filters (other than regex)

## 0.4.1 (2018-01-25)

* Remove Requeue version lock (#46)
Expand Down
25 changes: 25 additions & 0 deletions lib/resque_cleaner/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Structure has been borrowed from ResqueScheduler.
module ResqueCleaner
module Server
SENTRY_BASE_URL = "https://fullscript.sentry.io/issues/?utc=true"

def self.erb_path(filename)
File.join(File.dirname(__FILE__), 'server', 'views', filename)
Expand Down Expand Up @@ -234,6 +235,30 @@ def build_urls

@list_url = "cleaner_list?#{params}"
@dump_url = "cleaner_dump?#{params}"
build_sentry_url
end

def build_sentry_url
filter = {
transaction: @klass.present? ? @klass : "*Job"
}
if @exception.present?
filter["error.type"] = @exception
end
filter = filter.map {|key,value| "#{key}:#{value.to_s}"}.join(" ")
params = {
environment: Rails.env,
query: filter
}
if @from.present? || @to.present?
params["start"] = (@from.present? ? hours_ago(@from) : 28.days.ago).utc.iso8601
params["end"] = (@to.present? ? hours_ago(@to) : DateTime.now).utc.iso8601
end
params = params.map {|key,value| "#{key}=#{URI.encode_www_form_component(value.to_s)}"}.join("&")

@sentry_url = "#{SENTRY_BASE_URL}&#{params}"
rescue => error
# Skip displaying the sentry link upon unexpected filter format, but keep event list displayed
end

def filter_block
Expand Down
3 changes: 3 additions & 0 deletions lib/resque_cleaner/server/views/_cleaner_styles.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,7 @@
#main .cleaner div.dump{
float: right
}
#main .cleaner div.sentry{
float: left
}
</style>
5 changes: 5 additions & 0 deletions lib/resque_cleaner/server/views/_paginate.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<% end %>

</ul>
<% if @sentry_url %>
<div class="sentry">
<a href="<%= @sentry_url%>" target="_blank">Sentry</a>
</div>
<% end %>
<div class="dump">
<a href="<%= @dump_url%>" target="_blank">Dump</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resque-cleaner.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "resque-cleaner"
s.version = "0.4.1"
s.version = "0.5.0"
s.date = Time.now.strftime('%Y-%m-%d')
s.summary = "Resque plugin cleaning up failed jobs."
s.homepage = "https://github.com/ono/resque-cleaner"
Expand Down

0 comments on commit e0ac43e

Please sign in to comment.