Skip to content

Commit

Permalink
Merge ad5fcae into 6d2fc60
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Jun 21, 2021
2 parents 6d2fc60 + ad5fcae commit c937209
Show file tree
Hide file tree
Showing 22 changed files with 769 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/sentry_resque_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: sentry-resque Test

on:
workflow_dispatch:
push:
branches:
- master
- \d+-\d+
pull_request:
jobs:
test:
defaults:
run:
working-directory: sentry-resque
name: Test on ruby ${{ matrix.ruby_version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
ruby_version: [2.4, 2.5, 2.6, 2.7, '3.0', jruby]
os: [ubuntu-latest]
include:
- ruby_version: '3.0'
env: RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
steps:
- uses: actions/checkout@v1
- name: Set up Ruby ${{ matrix.ruby_version }}
uses: ruby/setup-ruby@v1
with:
bundler: 1
ruby-version: ${{ matrix.ruby_version }}

- name: Run specs
run: |
bundle install --jobs 4 --retry 3
bundle exec rake
11 changes: 11 additions & 0 deletions sentry-resque/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/

# rspec failure tracking
.rspec_status
2 changes: 2 additions & 0 deletions sentry-resque/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--format documentation
--color
44 changes: 44 additions & 0 deletions sentry-resque/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Changelog

Individual gem's changelog has been deprecated. Please check the [project changelog](https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md).

## 4.4.0

### Features

- Allow delayed job's exceptions to be reported to sentry until the last job retry [#1364](https://github.com/getsentry/sentry-ruby/pull/1364)

Add the `report_after_job_retries` configuration option to only report an exception to Sentry if this is the last job's retry after multiple exceptions.

```ruby
config.delayed_job.report_after_job_retries = true # default is false
```

- Use context for delayed_job's job info [#1395](https://github.com/getsentry/sentry-ruby/pull/1395)

**Before:**

<img width="60%" alt="job info in extra" src="https://user-images.githubusercontent.com/5079556/114307133-de856c00-9b10-11eb-8967-cd0e67e80539.png">

**After:**

<img width="60%" alt="job info in context" src="https://user-images.githubusercontent.com/5079556/114307135-e2b18980-9b10-11eb-9fc4-af885bf0f68d.png">

## 4.3.1

- Return delayed job when the SDK is not initialized [#1373](https://github.com/getsentry/sentry-ruby/pull/1373)
- Fixes [#1334](https://github.com/getsentry/sentry-ruby/issues/1334)

## 4.3.0

- No integration-specific changes

## 4.2.1

- Use ::Rails::Railtie for checking Rails definition [#1287](https://github.com/getsentry/sentry-ruby/pull/1284)
- Convert job id to string to avoid weird syntax error [#1285](https://github.com/getsentry/sentry-ruby/pull/1285)
- Fixes [#1282](https://github.com/getsentry/sentry-ruby/issues/1282)

## 4.2.0

- First release!
74 changes: 74 additions & 0 deletions sentry-resque/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at stan001212@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [https://contributor-covenant.org/version/1/4][version]

[homepage]: https://contributor-covenant.org
[version]: https://contributor-covenant.org/version/1/4/
22 changes: 22 additions & 0 deletions sentry-resque/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
source "https://rubygems.org"

# Specify your gem's dependencies in sentry-ruby.gemspec
gemspec

# TODO: Remove this if https://github.com/jruby/jruby/issues/6547 is addressed
gem "i18n", "<= 1.8.7"

gem "rake", "~> 12.0"
gem "rspec", "~> 3.0"
gem "codecov", "0.2.12"

gem "resque"
gem "rails"
gem "activerecord-jdbcmysql-adapter", platform: :jruby
gem "jdbc-sqlite3", platform: :jruby
gem "sqlite3", platform: :ruby

gem "sentry-ruby", path: "../sentry-ruby"
gem "sentry-rails", path: "../sentry-rails"

gem "pry"
21 changes: 21 additions & 0 deletions sentry-resque/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 st0012

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
3 changes: 3 additions & 0 deletions sentry-resque/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build:
bundle install
gem build sentry-delayed_job.gemspec
34 changes: 34 additions & 0 deletions sentry-resque/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<p align="center">
<a href="https://sentry.io" target="_blank" align="center">
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
</a>
<br>
</p>

# sentry-delayed_job, the DelayedJob integration for Sentry's Ruby client

---


[![Gem Version](https://img.shields.io/gem/v/sentry-delayed_job.svg)](https://rubygems.org/gems/sentry-delayed_job)
![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-delayed_job%20Test/badge.svg)
[![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master)
[![Gem](https://img.shields.io/gem/dt/sentry-delayed_job.svg)](https://rubygems.org/gems/sentry-delayed_job/)
[![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)


[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

The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.


## Getting Started

### Install

```ruby
gem "sentry-ruby"
gem "sentry-delayed_job"
```

Then you're all set! `sentry-delayed_job` will automatically insert a custom middleware and error handler to capture exceptions from your workers!
8 changes: 8 additions & 0 deletions sentry-resque/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec).tap do |task|
task.rspec_opts = "--order rand"
end

task :default => :spec
14 changes: 14 additions & 0 deletions sentry-resque/bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "sentry/ruby"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require "irb"
IRB.start(__FILE__)
8 changes: 8 additions & 0 deletions sentry-resque/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here
9 changes: 9 additions & 0 deletions sentry-resque/example/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source "https://rubygems.org"

gem "rails"
gem "sqlite3"
gem "resque"
gem "sentry-resque", path: "../"
gem "sentry-ruby", path: "../../sentry-ruby"

gem "pry"
44 changes: 44 additions & 0 deletions sentry-resque/example/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require "pry"
require "active_job"
require "resque"
require "sentry-resque"

Sentry.init do |config|
config.breadcrumbs_logger = [:sentry_logger]
# replace it with your sentry dsn
config.dsn = 'https://2fb45f003d054a7ea47feb45898f7649@o447951.ingest.sentry.io/5434472'
end

class MyJob < ActiveJob::Base
self.queue_adapter = :resque

def perform
raise "foo"
end
end

worker = Resque::Worker.new(:default)

MyJob.perform_later

begin
worker.work(0)
rescue => e
puts("active job failed because of \"#{e.message}\"")
end

class Foo
def self.perform
1 / 0
end
end

Resque::Job.create(:default, Foo)

begin
worker.work(0)
rescue => e
puts("inline job failed because of \"#{e.message}\"")
end


24 changes: 24 additions & 0 deletions sentry-resque/lib/sentry-resque.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require "resque"
require "sentry-ruby"
require "sentry/integrable"
require "sentry/resque/configuration"
require "sentry/resque/version"
require "sentry/resque"

module Sentry
module Resque
extend Sentry::Integrable

register_integration name: "resque", version: Sentry::Resque::VERSION

if defined?(::Rails::Railtie)
class Railtie < ::Rails::Railtie
config.after_initialize do
next unless Sentry.initialized?

Sentry.configuration.rails.skippable_job_adapters << "ActiveJob::QueueAdapters::ResqueAdapter"
end
end
end
end
end
Loading

0 comments on commit c937209

Please sign in to comment.