sentry-resque 4.6.0.pre.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +21 -0
- data/Makefile +3 -0
- data/README.md +34 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/Gemfile +9 -0
- data/example/app.rb +44 -0
- data/lib/sentry-resque.rb +24 -0
- data/lib/sentry/resque.rb +69 -0
- data/lib/sentry/resque/configuration.rb +21 -0
- data/lib/sentry/resque/version.rb +5 -0
- data/sentry-resque.gemspec +26 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 467c7b903c10db6a93147cd1ed995ba62a7bdc655a3c43a0372b0dba73089076
|
4
|
+
data.tar.gz: 7f890a79cbff1b85157d9fffcc196ee210e879689e179c84c09d0b382e30bd7b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 66f698fb4cf9864526047899411d93b1c82b06445f482e5ce612c5a5eb6be8c6f6c03d9009673ebebcd889f3cf58a523fc3ce8a183b0a17b7f619a3b7b2249a9
|
7
|
+
data.tar.gz: 9e93e081270ac2f9a46f6eb7ccbfc5f20f7547e235f1a41765fedc3e116b79ddcb5da306bc34b8c3d730cbf79b8022ae7f883141259e3d89a910738cb9d7ad9c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at stan001212@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in sentry-ruby.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "rake", "~> 12.0"
|
7
|
+
gem "rspec", "~> 3.0"
|
8
|
+
gem "codecov", "0.2.12"
|
9
|
+
|
10
|
+
gem "resque"
|
11
|
+
gem "rails"
|
12
|
+
|
13
|
+
gem "sentry-ruby", path: "../sentry-ruby"
|
14
|
+
gem "sentry-rails", path: "../sentry-rails"
|
15
|
+
|
16
|
+
gem "pry"
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 st0012
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<a href="https://sentry.io" target="_blank" align="center">
|
3
|
+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
|
4
|
+
</a>
|
5
|
+
<br>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
# sentry-resque, the Resque integration for Sentry's Ruby client
|
9
|
+
|
10
|
+
---
|
11
|
+
|
12
|
+
|
13
|
+
[](https://rubygems.org/gems/sentry-resque)
|
14
|
+

|
15
|
+
[](https://codecov.io/gh/getsentry/sentry-ruby/branch/master)
|
16
|
+
[](https://rubygems.org/gems/sentry-resque/)
|
17
|
+
[](https://dependabot.com/compatibility-score.html?dependency-name=sentry-resque&package-manager=bundler&version-scheme=semver)
|
18
|
+
|
19
|
+
|
20
|
+
[Documentation](https://docs.sentry.io/platforms/ruby/guides/resque/) | [Bug Tracker](https://github.com/getsentry/sentry-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
|
21
|
+
|
22
|
+
The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
|
23
|
+
|
24
|
+
|
25
|
+
## Getting Started
|
26
|
+
|
27
|
+
### Install
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem "sentry-ruby"
|
31
|
+
gem "sentry-resque"
|
32
|
+
```
|
33
|
+
|
34
|
+
Then you're all set! `sentry-resque` will automatically insert a custom middleware and error handler to capture exceptions from your workers!
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sentry/ruby"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/example/Gemfile
ADDED
data/example/app.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "pry"
|
2
|
+
require "active_job"
|
3
|
+
require "resque"
|
4
|
+
require "sentry-resque"
|
5
|
+
|
6
|
+
Sentry.init do |config|
|
7
|
+
config.breadcrumbs_logger = [:sentry_logger]
|
8
|
+
# replace it with your sentry dsn
|
9
|
+
config.dsn = 'https://2fb45f003d054a7ea47feb45898f7649@o447951.ingest.sentry.io/5434472'
|
10
|
+
end
|
11
|
+
|
12
|
+
class MyJob < ActiveJob::Base
|
13
|
+
self.queue_adapter = :resque
|
14
|
+
|
15
|
+
def perform
|
16
|
+
raise "foo"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
worker = Resque::Worker.new(:default)
|
21
|
+
|
22
|
+
MyJob.perform_later
|
23
|
+
|
24
|
+
begin
|
25
|
+
worker.work(0)
|
26
|
+
rescue => e
|
27
|
+
puts("active job failed because of \"#{e.message}\"")
|
28
|
+
end
|
29
|
+
|
30
|
+
class Foo
|
31
|
+
def self.perform
|
32
|
+
1 / 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Resque::Job.create(:default, Foo)
|
37
|
+
|
38
|
+
begin
|
39
|
+
worker.work(0)
|
40
|
+
rescue => e
|
41
|
+
puts("inline job failed because of \"#{e.message}\"")
|
42
|
+
end
|
43
|
+
|
44
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "resque"
|
2
|
+
require "sentry-ruby"
|
3
|
+
require "sentry/integrable"
|
4
|
+
require "sentry/resque/configuration"
|
5
|
+
require "sentry/resque/version"
|
6
|
+
require "sentry/resque"
|
7
|
+
|
8
|
+
module Sentry
|
9
|
+
module Resque
|
10
|
+
extend Sentry::Integrable
|
11
|
+
|
12
|
+
register_integration name: "resque", version: Sentry::Resque::VERSION
|
13
|
+
|
14
|
+
if defined?(::Rails::Railtie)
|
15
|
+
class Railtie < ::Rails::Railtie
|
16
|
+
config.after_initialize do
|
17
|
+
next unless Sentry.initialized?
|
18
|
+
|
19
|
+
Sentry.configuration.rails.skippable_job_adapters << "ActiveJob::QueueAdapters::ResqueAdapter"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "resque"
|
4
|
+
|
5
|
+
module Sentry
|
6
|
+
module Resque
|
7
|
+
def perform
|
8
|
+
return super unless Sentry.initialized?
|
9
|
+
|
10
|
+
Sentry.with_scope do |scope|
|
11
|
+
begin
|
12
|
+
contexts = generate_contexts
|
13
|
+
scope.set_contexts(**contexts)
|
14
|
+
scope.set_tags("resque.queue" => queue)
|
15
|
+
|
16
|
+
scope.set_transaction_name(contexts.dig(:"Active-Job", :job_class) || contexts.dig(:"Resque", :job_class))
|
17
|
+
transaction = Sentry.start_transaction(name: scope.transaction_name, op: "resque")
|
18
|
+
scope.set_span(transaction) if transaction
|
19
|
+
|
20
|
+
super
|
21
|
+
|
22
|
+
finish_transaction(transaction, 200)
|
23
|
+
rescue Exception => exception
|
24
|
+
::Sentry::Resque.capture_exception(exception, hint: { background: false })
|
25
|
+
finish_transaction(transaction, 500)
|
26
|
+
raise
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def generate_contexts
|
32
|
+
context = {}
|
33
|
+
|
34
|
+
if payload["class"] == "ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper"
|
35
|
+
active_job_payload = payload["args"].first
|
36
|
+
|
37
|
+
context[:"Active-Job"] = {
|
38
|
+
job_class: active_job_payload["job_class"],
|
39
|
+
job_id: active_job_payload["job_id"],
|
40
|
+
arguments: active_job_payload["arguments"],
|
41
|
+
executions: active_job_payload["executions"],
|
42
|
+
exception_executions: active_job_payload["exception_executions"],
|
43
|
+
locale: active_job_payload["locale"],
|
44
|
+
enqueued_at: active_job_payload["enqueued_at"],
|
45
|
+
queue: queue,
|
46
|
+
worker: worker.to_s
|
47
|
+
}
|
48
|
+
else
|
49
|
+
context[:"Resque"] = {
|
50
|
+
job_class: payload["class"],
|
51
|
+
arguments: payload["args"],
|
52
|
+
queue: queue,
|
53
|
+
worker: worker.to_s
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
context
|
58
|
+
end
|
59
|
+
|
60
|
+
def finish_transaction(transaction, status)
|
61
|
+
return unless transaction
|
62
|
+
|
63
|
+
transaction.set_http_status(status)
|
64
|
+
transaction.finish
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
Resque::Job.send(:prepend, Sentry::Resque)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Sentry
|
2
|
+
class Configuration
|
3
|
+
attr_reader :resque
|
4
|
+
|
5
|
+
add_post_initialization_callback do
|
6
|
+
@resque = Sentry::Resque::Configuration.new
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Resque
|
11
|
+
class Configuration
|
12
|
+
# Set this option to true if you want Sentry to only capture the last job
|
13
|
+
# retry if it fails.
|
14
|
+
attr_accessor :report_after_job_retries
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@report_after_job_retries = false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative "lib/sentry/resque/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "sentry-resque"
|
5
|
+
spec.version = Sentry::Resque::VERSION
|
6
|
+
spec.authors = ["Sentry Team"]
|
7
|
+
spec.description = spec.summary = "A gem that provides Resque integration for the Sentry error logger"
|
8
|
+
spec.email = "accounts@sentry.io"
|
9
|
+
spec.license = 'Apache-2.0'
|
10
|
+
spec.homepage = "https://github.com/getsentry/sentry-ruby"
|
11
|
+
|
12
|
+
spec.platform = Gem::Platform::RUBY
|
13
|
+
spec.required_ruby_version = '>= 2.4'
|
14
|
+
spec.extra_rdoc_files = ["README.md", "LICENSE.txt"]
|
15
|
+
spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples)'`.split("\n")
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
20
|
+
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "sentry-ruby-core", "~> 4.6.0-beta.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sentry-resque
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.6.0.pre.beta.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sentry Team
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-06-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sentry-ruby-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.6.0.pre.beta.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.6.0.pre.beta.0
|
27
|
+
description: A gem that provides Resque integration for the Sentry error logger
|
28
|
+
email: accounts@sentry.io
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.md
|
33
|
+
- LICENSE.txt
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- ".rspec"
|
37
|
+
- CODE_OF_CONDUCT.md
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- Makefile
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/console
|
44
|
+
- bin/setup
|
45
|
+
- example/Gemfile
|
46
|
+
- example/app.rb
|
47
|
+
- lib/sentry-resque.rb
|
48
|
+
- lib/sentry/resque.rb
|
49
|
+
- lib/sentry/resque/configuration.rb
|
50
|
+
- lib/sentry/resque/version.rb
|
51
|
+
- sentry-resque.gemspec
|
52
|
+
homepage: https://github.com/getsentry/sentry-ruby
|
53
|
+
licenses:
|
54
|
+
- Apache-2.0
|
55
|
+
metadata:
|
56
|
+
homepage_uri: https://github.com/getsentry/sentry-ruby
|
57
|
+
source_code_uri: https://github.com/getsentry/sentry-ruby
|
58
|
+
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2.4'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.3.1
|
73
|
+
requirements: []
|
74
|
+
rubygems_version: 3.1.6
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: A gem that provides Resque integration for the Sentry error logger
|
78
|
+
test_files: []
|