File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -64,8 +64,7 @@ def operation_name(query)
6464
6565 class Event < MonitorTrace ::Monitor ::Event
6666 def start
67- if Sentry . initialized?
68- @span = Sentry . get_current_scope . get_span
67+ if Sentry . initialized? && ( @span = Sentry . get_current_scope . get_span )
6968 span_name = @monitor . name_for ( @keyword , @object )
7069 @span . start_child ( op : span_name )
7170 end
Original file line number Diff line number Diff line change @@ -47,6 +47,13 @@ class SchemaWithTransactionName < GraphQL::Schema
4747 assert res . context [ :other_trace_ran ]
4848 end
4949
50+ it "handles cases when Sentry has no current span" do
51+ Sentry . use_nil_span = true
52+ assert SentryTraceTest ::SchemaWithoutTransactionName . execute ( "{ int }" )
53+ ensure
54+ Sentry . use_nil_span = false
55+ end
56+
5057 describe "When Sentry is not configured" do
5158 it "does not initialize any spans" do
5259 Sentry . stub ( :initialized? , false ) do
Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ module Sentry
1111 SPAN_DESCRIPTIONS = [ ]
1212 TRANSACTION_NAMES = [ ]
1313
14+ class << self
15+ attr_accessor :use_nil_span
16+ end
17+
1418 def self . initialized?
1519 true
1620 end
@@ -24,7 +28,7 @@ def self.get_current_scope
2428 end
2529
2630 def self . get_span
27- DummySpan
31+ use_nil_span ? nil : DummySpan
2832 end
2933
3034 def self . with_child_span ( **args , &block )
You can’t perform that action at this time.
0 commit comments