Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikspang authored Aug 27, 2024
2 parents 407d457 + 4db5f74 commit 6eaf81b
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_batch_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Build gem source
run: ruby .scripts/batch_build.rb
- name: Archive Artifacts
uses: actions/upload-artifact@v3.1.1
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}
path: sentry*/*.gem
2 changes: 1 addition & 1 deletion .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
working-directory: ${{env.sdk-directory}}
run: make build
- name: Archive Artifacts
uses: actions/upload-artifact@v3.1.1
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}
path: ${{env.sdk-directory}}/*.gem
11 changes: 8 additions & 3 deletions .github/workflows/sentry_ruby_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
fail-fast: false
matrix:
ruby_version: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
rack_version: [2.0, 3.0]
rack_version: [2.0, 3.0, 3.1]
redis_rb_version: [4.0]
include:
- { ruby_version: 3.2, rack_version: 0, redis_rb_version: 5.0 }
Expand All @@ -45,8 +45,12 @@ jobs:
}
- {
ruby_version: 3.2,
rack_version: 3.0,
redis_rb_version: 5.0,
rack_version: 3.0
}
- {
ruby_version: 3.3,
rack_version: 3.1,
redis_rb_version: 5.3,
options: { codecov: 1 },
}
steps:
Expand All @@ -69,6 +73,7 @@ jobs:
RACK_VERSION: ${{ matrix.rack_version }}
REDIS_RB_VERSION: ${{ matrix.redis_rb_version }}
run: |
bundle config set without 'rubocop'
bundle install --jobs 4 --retry 3
bundle exec rake
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Unreleased

### Features

- Add support for $SENTRY_DEBUG and $SENTRY_SPOTLIGHT ([#2374](https://github.com/getsentry/sentry-ruby/pull/2374))
- Support human readable intervals in `sidekiq-cron` ([#2387](https://github.com/getsentry/sentry-ruby/pull/2387))
- Add support for Sentry Cache instrumentation, when using Rails.cache ([#2380](https://github.com/getsentry/sentry-ruby/pull/2380))

## 5.19.0
Expand Down Expand Up @@ -32,7 +35,7 @@
```

- Transaction data are now included in the context ([#2365](https://github.com/getsentry/sentry-ruby/pull/2365))
- Closes [#2364](https://github.com/getsentry/sentry-ruby/issues/2363)
- Closes [#2363](https://github.com/getsentry/sentry-ruby/issues/2363)

- Inject Sentry meta tags in the Rails application layout automatically in the generator ([#2369](https://github.com/getsentry/sentry-ruby/pull/2369))

Expand Down
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ gem "simplecov"
gem "simplecov-cobertura", "~> 1.4"
gem "rexml"

gem "rubocop-rails-omakase"
gem "rubocop-packaging"
group :rubocop do
gem "rubocop-rails-omakase"
gem "rubocop-packaging"
end
2 changes: 1 addition & 1 deletion sentry-ruby/spec/sentry/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
end
end

context 'rack context specified', rack: true do
context 'rack context specified', when: :rack_available? do
require 'stringio'

before do
Expand Down
4 changes: 1 addition & 3 deletions sentry-ruby/spec/sentry/profiler_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require "spec_helper"

return unless defined?(StackProf)

RSpec.describe Sentry::Profiler do
RSpec.describe Sentry::Profiler, when: :stack_prof_installed? do
before do
perform_basic_setup do |config|
config.traces_sample_rate = 1.0
Expand Down
50 changes: 24 additions & 26 deletions sentry-ruby/spec/sentry/rack/capture_exceptions_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require 'spec_helper'

return unless defined?(Rack)

RSpec.describe Sentry::Rack::CaptureExceptions, rack: true do
RSpec.describe 'Sentry::Rack::CaptureExceptions', when: :rack_available? do
let(:exception) { ZeroDivisionError.new("divided by 0") }
let(:additional_headers) { {} }
let(:env) { Rack::MockRequest.env_for("/test", additional_headers) }
Expand All @@ -14,7 +12,7 @@

it 'captures the exception from direct raise' do
app = ->(_e) { raise exception }
stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

expect { stack.call(env) }.to raise_error(ZeroDivisionError)

Expand All @@ -27,7 +25,7 @@

it 'has the correct mechanism' do
app = ->(_e) { raise exception }
stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

expect { stack.call(env) }.to raise_error(ZeroDivisionError)

Expand All @@ -41,7 +39,7 @@
e['rack.exception'] = exception
[200, {}, ['okay']]
end
stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

expect do
stack.call(env)
Expand All @@ -57,7 +55,7 @@
e['sinatra.error'] = exception
[200, {}, ['okay']]
end
stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

expect do
stack.call(env)
Expand All @@ -72,7 +70,7 @@
e['rack.exception'] = exception
[200, {}, ['okay']]
end
stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

stack.call(env)

Expand All @@ -88,7 +86,7 @@
[200, { 'content-type' => 'text/plain' }, ['OK']]
end

stack = described_class.new(Rack::Lint.new(app))
stack = Sentry::Rack::CaptureExceptions.new(Rack::Lint.new(app))
expect { stack.call(env) }.to_not raise_error
expect(env.key?("sentry.error_event_id")).to eq(false)
end
Expand All @@ -111,7 +109,7 @@
a / b
end

stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

expect { stack.call(env) }.to raise_error(ZeroDivisionError)

Expand All @@ -135,7 +133,7 @@ def inspect
a / b
end

stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

expect { stack.call(env) }.to raise_error(ZeroDivisionError)

Expand All @@ -153,7 +151,7 @@ def inspect
a / b
end

stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

expect { stack.call(env) }.to raise_error(ZeroDivisionError)

Expand Down Expand Up @@ -181,7 +179,7 @@ def inspect
[200, {}, ["ok"]]
end

app_1 = described_class.new(request_1)
app_1 = Sentry::Rack::CaptureExceptions.new(request_1)

app_1.call(env)

Expand All @@ -195,7 +193,7 @@ def inspect
Sentry.capture_message("test")
[200, {}, ["ok"]]
end
app_1 = described_class.new(request_1)
app_1 = Sentry::Rack::CaptureExceptions.new(request_1)

app_1.call(env)

Expand All @@ -209,7 +207,7 @@ def inspect
e['rack.exception'] = Exception.new
[200, {}, ["ok"]]
end
app_1 = described_class.new(request_1)
app_1 = Sentry::Rack::CaptureExceptions.new(request_1)
app_1.call(env)

event = last_sentry_event
Expand All @@ -221,7 +219,7 @@ def inspect
e['rack.exception'] = Exception.new
[200, {}, ["ok"]]
end
app_2 = described_class.new(request_2)
app_2 = Sentry::Rack::CaptureExceptions.new(request_2)
app_2.call(env)

event = last_sentry_event
Expand Down Expand Up @@ -250,7 +248,7 @@ def inspect
end

let(:stack) do
described_class.new(
Sentry::Rack::CaptureExceptions.new(
->(_) do
[200, {}, ["ok"]]
end
Expand Down Expand Up @@ -438,7 +436,7 @@ def will_be_sampled_by_sdk
[200, {}, ["ok"]]
end

stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

stack.call(env)

Expand All @@ -462,7 +460,7 @@ def will_be_sampled_by_sdk
end
end

stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

stack.call(env)

Expand Down Expand Up @@ -496,7 +494,7 @@ def will_be_sampled_by_sdk
[200, {}, ["ok"]]
end

stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

stack.call(env)

Expand All @@ -514,7 +512,7 @@ def will_be_sampled_by_sdk
raise "foo"
end

stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

expect do
stack.call(env)
Expand All @@ -541,7 +539,7 @@ def will_be_sampled_by_sdk
end

let(:stack) do
described_class.new(
Sentry::Rack::CaptureExceptions.new(
->(_) do
[200, {}, ["ok"]]
end
Expand Down Expand Up @@ -588,7 +586,7 @@ def will_be_sampled_by_sdk

let(:stack) do
app = ->(_e) { raise exception }
described_class.new(app)
Sentry::Rack::CaptureExceptions.new(app)
end

before { perform_basic_setup }
Expand Down Expand Up @@ -620,7 +618,7 @@ def will_be_sampled_by_sdk

expect_any_instance_of(Sentry::Hub).not_to receive(:start_session)
expect(Sentry.session_flusher).to be_nil
stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)
stack.call(env)

expect(sentry_envelopes.count).to eq(0)
Expand All @@ -646,7 +644,7 @@ def will_be_sampled_by_sdk
end
end

stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)

expect(Sentry.session_flusher).not_to be_nil

Expand Down Expand Up @@ -709,7 +707,7 @@ def will_be_sampled_by_sdk
[200, {}, "ok"]
end

stack = described_class.new(app)
stack = Sentry::Rack::CaptureExceptions.new(app)
stack.call(env)
event = last_sentry_event

Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/spec/sentry/scope/setters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
new_breadcrumb
end

describe "#set_rack_env", rack: true do
describe "#set_rack_env", when: :rack_available? do
let(:env) do
Rack::MockRequest.env_for("/test", {})
end
Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/spec/sentry/scope_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
expect(event.dynamic_sampling_context).to eq(subject.propagation_context.get_dynamic_sampling_context)
end

context "with Rack", rack: true do
context "with Rack", when: :rack_available? do
let(:env) do
Rack::MockRequest.env_for("/test", {})
end
Expand Down
16 changes: 14 additions & 2 deletions sentry-ruby/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
ENV.delete('RACK_ENV')
end

config.before(:each, rack: true) do
skip("skip rack related tests") unless defined?(Rack)
config.before(:each, when: true) do |example|
meth = example.metadata[:when]

skip("Skipping because `when: #{meth}` returned false") unless TestHelpers.public_send(meth, example)
end

RSpec::Matchers.define :have_recorded_lost_event do |reason, data_category, num: 1|
Expand All @@ -57,6 +59,16 @@
end
end

module TestHelpers
def self.stack_prof_installed?(_example)
defined?(StackProf)
end

def self.rack_available?(_example)
defined?(Rack)
end
end

def fixtures_root
@fixtures_root ||= Pathname(__dir__).join("fixtures")
end
Expand Down
4 changes: 2 additions & 2 deletions sentry-sidekiq/lib/sentry/sidekiq/cron/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def save
unless klass_const.send(:ancestors).include?(Sentry::Cron::MonitorCheckIns)
klass_const.send(:include, Sentry::Cron::MonitorCheckIns)
klass_const.send(:sentry_monitor_check_ins,
slug: name,
monitor_config: Sentry::Cron::MonitorConfig.from_crontab(cron))
slug: name.to_s,
monitor_config: Sentry::Cron::MonitorConfig.from_crontab(parsed_cron.original))
end

true
Expand Down
4 changes: 4 additions & 0 deletions sentry-sidekiq/spec/fixtures/sidekiq-cron-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ manual:
cron: "* * * * *"
class: "SadWorkerWithCron"

human_readable_cron:
cron: "every 5 minutes"
class: HappyWorkerWithHumanReadableCron

invalid_cron:
cron: "not a crontab"
class: "ReportingWorker"
Loading

0 comments on commit 6eaf81b

Please sign in to comment.