diff --git a/lib/graphql/tracing/sentry_trace.rb b/lib/graphql/tracing/sentry_trace.rb index 744a40d424..684ea1efd6 100644 --- a/lib/graphql/tracing/sentry_trace.rb +++ b/lib/graphql/tracing/sentry_trace.rb @@ -16,8 +16,8 @@ module SentryTrace "execute_query_lazy" => "graphql.execute" }.each do |trace_method, platform_key| module_eval <<-RUBY, __FILE__, __LINE__ - def #{trace_method}(**data, &block) - instrument_execution("#{platform_key}", "#{trace_method}", data, &block) + def #{trace_method}(**data) + instrument_execution("#{platform_key}", "#{trace_method}", data) { super } end RUBY end diff --git a/spec/graphql/tracing/sentry_trace_spec.rb b/spec/graphql/tracing/sentry_trace_spec.rb index f80ee6a79e..2dd0db62d2 100644 --- a/spec/graphql/tracing/sentry_trace_spec.rb +++ b/spec/graphql/tracing/sentry_trace_spec.rb @@ -22,6 +22,13 @@ def thing; :thing; end query(Query) + module OtherTrace + def execute_query(query:) + query.context[:other_trace_ran] = true + super + end + end + trace_with OtherTrace trace_with GraphQL::Tracing::SentryTrace end @@ -29,6 +36,11 @@ def thing; :thing; end Sentry.clear_all end + it "works with other trace modules" do + res = SentryTraceTestSchema.execute("{ int }") + assert res.context[:other_trace_ran] + end + describe "When Sentry is not configured" do it "does not initialize any spans" do Sentry.stub(:initialized?, false) do