sentry-delayed_job 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: db868f6352945d274c05edc038c741fad9d416735bd68df6550af2f56f58ffb4
4
+ data.tar.gz: 7e64583c842ddb8e54d37866af6098377182f10c30120f51981c0f7944a5f2d3
5
+ SHA512:
6
+ metadata.gz: 215f4e41121897b18f5b0b15eea29c50c583ce10e2d07536cca40d878b9de912df700256f1d54949cb4687e859a6b6121b116c27538314706fbf369cdffd5f67
7
+ data.tar.gz: 6a5aeaed988bcd76e6da51cc16affdec0677f456a020bcf9b8630acb0d22dff8a63627c60e0e6e66a7a4d36f7dcb73f504927385500fe07e00eb6780d8c8929a
data/.craft.yml ADDED
@@ -0,0 +1,19 @@
1
+ minVersion: '0.13.2'
2
+ github:
3
+ owner: getsentry
4
+ repo: sentry-ruby
5
+ changelogPolicy: simple
6
+ preReleaseCommand: ruby ../.scripts/bump-version.rb
7
+ releaseBranchPrefix: release-sentry-delayed_job
8
+ statusProvider:
9
+ name: github
10
+ artifactProvider:
11
+ name: github
12
+ targets:
13
+ - name: gem
14
+ - name: github
15
+ tagPrefix: sentry-delayed_job-v
16
+ - name: registry
17
+ type: sdk
18
+ config:
19
+ canonical: 'gem:sentry-delayed_job'
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 4.2.0
4
+
5
+ - First release!
@@ -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,23 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sentry-ruby.gemspec
4
+ gemspec
5
+
6
+ # TODO: Remove this if https://github.com/jruby/jruby/issues/6547 is addressed
7
+ gem "i18n", "<= 1.8.7"
8
+
9
+ gem "rake", "~> 12.0"
10
+ gem "rspec", "~> 3.0"
11
+ gem "codecov", "0.2.12"
12
+
13
+ gem "delayed_job"
14
+ gem "delayed_job_active_record"
15
+ gem "rails"
16
+ gem "activerecord-jdbcmysql-adapter", platform: :jruby
17
+ gem "jdbc-sqlite3", platform: :jruby
18
+ gem "sqlite3", platform: :ruby
19
+
20
+ gem "sentry-ruby", path: "../sentry-ruby"
21
+ gem "sentry-rails", path: "../sentry-rails"
22
+
23
+ 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
@@ -0,0 +1,3 @@
1
+ build:
2
+ bundle install
3
+ gem build sentry-delayed_job.gemspec
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-delayed_job, the DelayedJob integration for Sentry's Ruby client
9
+
10
+ ---
11
+
12
+
13
+ [![Gem Version](https://img.shields.io/gem/v/sentry-delayed_job.svg)](https://rubygems.org/gems/sentry-delayed_job)
14
+ ![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-delayed_job%20Test/badge.svg)
15
+ [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master)
16
+ [![Gem](https://img.shields.io/gem/dt/sentry-delayed_job.svg)](https://rubygems.org/gems/sentry-delayed_job/)
17
+ [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-delayed_job&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-delayed_job&package-manager=bundler&version-scheme=semver)
18
+
19
+
20
+ [Documentation](https://docs.sentry.io/platforms/ruby/guides/delayed_job/) | [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-delayed_job"
32
+ ```
33
+
34
+ Then you're all set! `sentry-delayed_job` will automatically insert a custom middleware and error handler to capture exceptions from your workers!
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec).tap do |task|
5
+ task.rspec_opts = "--order rand"
6
+ end
7
+
8
+ task :default => :spec
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/example/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails"
4
+ gem "sqlite3"
5
+ gem "delayed_job"
6
+ gem 'delayed_job_active_record'
7
+ gem "sentry-delayed_job", path: "../"
8
+ gem "sentry-ruby", path: "../../sentry-ruby"
9
+
10
+ gem "pry"
data/example/app.rb ADDED
@@ -0,0 +1,68 @@
1
+ require "pry"
2
+ require "active_job"
3
+ require "active_record"
4
+ require "delayed_job"
5
+ require "delayed_job_active_record"
6
+ require "sentry-delayed_job"
7
+ # require "logger"
8
+
9
+ # This connection will do for database-independent bug reports.
10
+ ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
11
+ # ActiveRecord::Base.logger = Logger.new(STDOUT)
12
+
13
+ ActiveRecord::Schema.define do
14
+ create_table :delayed_jobs do |table|
15
+ table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
16
+ table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
17
+ table.text :handler, null: false # YAML-encoded string of the object that will do work
18
+ table.text :last_error # reason for last failure (See Note below)
19
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
20
+ table.datetime :locked_at # Set when a client is working on this object
21
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
22
+ table.string :locked_by # Who is working on this object (if locked)
23
+ table.string :queue # The name of the queue this job is in
24
+ table.timestamps null: true
25
+ end
26
+ end
27
+
28
+ Sentry.init do |config|
29
+ config.breadcrumbs_logger = [:sentry_logger]
30
+ # replace it with your sentry dsn
31
+ config.dsn = 'https://2fb45f003d054a7ea47feb45898f7649@o447951.ingest.sentry.io/5434472'
32
+ end
33
+
34
+ class MyJob < ActiveJob::Base
35
+ self.queue_adapter = :delayed_job
36
+
37
+ def perform
38
+ raise "foo"
39
+ end
40
+ end
41
+
42
+ MyJob.perform_later
43
+
44
+ enqueued_job = Delayed::Backend::ActiveRecord::Job.last
45
+
46
+ begin
47
+ enqueued_job.invoke_job
48
+ rescue => e
49
+ puts("active job failed because of \"#{e.message}\"")
50
+ end
51
+
52
+ class Foo
53
+ def bar
54
+ 1 / 0
55
+ end
56
+ end
57
+
58
+ Foo.new.delay.bar
59
+
60
+ enqueued_job = Delayed::Backend::ActiveRecord::Job.last
61
+
62
+ begin
63
+ enqueued_job.invoke_job
64
+ rescue => e
65
+ puts("inline job failed because of \"#{e.message}\"")
66
+ end
67
+
68
+
@@ -0,0 +1,23 @@
1
+ require "delayed_job"
2
+ require "sentry-ruby"
3
+ require "sentry/integrable"
4
+ require "sentry/delayed_job/version"
5
+ require "sentry/delayed_job/plugin"
6
+
7
+ module Sentry
8
+ module DelayedJob
9
+ extend Sentry::Integrable
10
+
11
+ register_integration name: "delayed_job", version: Sentry::DelayedJob::VERSION
12
+
13
+ if defined?(::Rails)
14
+ class Railtie < ::Rails::Railtie
15
+ config.after_initialize do
16
+ next unless Sentry.initialized?
17
+
18
+ Sentry.configuration.rails.skippable_job_adapters << "ActiveJob::QueueAdapters::DelayedJobAdapter"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+ require "delayed_job"
3
+
4
+ module Sentry
5
+ module DelayedJob
6
+ class Plugin < ::Delayed::Plugin
7
+ callbacks do |lifecycle|
8
+ lifecycle.around(:invoke_job) do |job, *args, &block|
9
+ Sentry.with_scope do |scope|
10
+ scope.set_extras(**generate_extra(job))
11
+ scope.set_tags("delayed_job.queue" => job.queue, "delayed_job.id" => job.id)
12
+
13
+ begin
14
+ block.call(job, *args)
15
+ rescue Exception => e
16
+ Sentry::DelayedJob.capture_exception(e, hint: { background: false })
17
+
18
+ raise
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ def self.generate_extra(job)
25
+ extra = {
26
+ "delayed_job.id": job.id,
27
+ "delayed_job.priority": job.priority,
28
+ "delayed_job.attempts": job.attempts,
29
+ "delayed_job.run_at": job.run_at,
30
+ "delayed_job.locked_at": job.locked_at,
31
+ "delayed_job.locked_by": job.locked_by,
32
+ "delayed_job.queue": job.queue,
33
+ "delayed_job.created_at": job.created_at,
34
+ "delayed_job.last_error": job.last_error&.byteslice(0..1000),
35
+ "delayed_job.handler": job.handler&.byteslice(0..1000)
36
+ }
37
+
38
+ if job.payload_object.respond_to?(:job_data)
39
+ job.payload_object.job_data.each do |key, value|
40
+ extra[:"active_job.#{key}"] = value
41
+ end
42
+ end
43
+
44
+ extra
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ Delayed::Worker.plugins << Sentry::DelayedJob::Plugin
@@ -0,0 +1,5 @@
1
+ module Sentry
2
+ module DelayedJob
3
+ VERSION = "4.2.0"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ require_relative "lib/sentry/delayed_job/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "sentry-delayed_job"
5
+ spec.version = Sentry::DelayedJob::VERSION
6
+ spec.authors = ["Sentry Team"]
7
+ spec.description = spec.summary = "A gem that provides DelayedJob 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/sentry-delayed_job/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.2.0"
26
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sentry-delayed_job
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Sentry Team
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-02-09 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.2.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.2.0
27
+ description: A gem that provides DelayedJob 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
+ - ".craft.yml"
36
+ - ".gitignore"
37
+ - ".rspec"
38
+ - CHANGELOG.md
39
+ - CODE_OF_CONDUCT.md
40
+ - Gemfile
41
+ - LICENSE.txt
42
+ - Makefile
43
+ - README.md
44
+ - Rakefile
45
+ - bin/console
46
+ - bin/setup
47
+ - example/Gemfile
48
+ - example/app.rb
49
+ - lib/sentry-delayed_job.rb
50
+ - lib/sentry/delayed_job/plugin.rb
51
+ - lib/sentry/delayed_job/version.rb
52
+ - sentry-delayed_job.gemspec
53
+ homepage: https://github.com/getsentry/sentry-ruby
54
+ licenses:
55
+ - Apache-2.0
56
+ metadata:
57
+ homepage_uri: https://github.com/getsentry/sentry-ruby
58
+ source_code_uri: https://github.com/getsentry/sentry-ruby
59
+ changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/sentry-delayed_job/CHANGELOG.md
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '2.4'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 3.0.3
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: A gem that provides DelayedJob integration for the Sentry error logger
79
+ test_files: []