From 19dbad821d249f3aeed7336e1b8025b1d3986f7f Mon Sep 17 00:00:00 2001 From: Robert Mosolgo Date: Wed, 7 Feb 2024 14:54:12 -0500 Subject: [PATCH] Fix sentry trace super calls --- lib/graphql/tracing/sentry_trace.rb | 4 ++-- spec/graphql/tracing/sentry_trace_spec.rb | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/graphql/tracing/sentry_trace.rb b/lib/graphql/tracing/sentry_trace.rb index 35d890af5d..d11a60ea05 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 d75bd52a5c..4555b15d76 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