diff --git a/sentry-ruby/lib/sentry/faraday.rb b/sentry-ruby/lib/sentry/faraday.rb index 7a53b26c7..05d5f45bd 100644 --- a/sentry-ruby/lib/sentry/faraday.rb +++ b/sentry-ruby/lib/sentry/faraday.rb @@ -29,7 +29,7 @@ class Instrumenter include Utils::HttpTracing def instrument(op_name, env, &block) - return unless Sentry.initialized? + return block.call unless Sentry.initialized? Sentry.with_child_span(op: op_name, start_timestamp: Sentry.utc_now.to_f, origin: SPAN_ORIGIN) do |sentry_span| request_info = extract_request_info(env) diff --git a/sentry-ruby/spec/sentry/faraday_spec.rb b/sentry-ruby/spec/sentry/faraday_spec.rb index abb63ddb5..f4632032f 100644 --- a/sentry-ruby/spec/sentry/faraday_spec.rb +++ b/sentry-ruby/spec/sentry/faraday_spec.rb @@ -254,4 +254,26 @@ expect(transaction.span_recorder.spans.map(&:origin)).not_to include("auto.http.faraday") end end + + context "when Sentry is not initialized" do + let(:http) do + Faraday.new(url) do |f| + f.adapter Faraday::Adapter::Test do |stub| + stub.get("/test") do + [200, { "Content-Type" => "text/html" }, "