Skip to content

Commit

Permalink
Merge pull request #4830 from rmosolgo/sentry-trace-fix
Browse files Browse the repository at this point in the history
Fix sentry trace super calls
  • Loading branch information
rmosolgo authored Feb 7, 2024
2 parents 35b7851 + 19dbad8 commit 8ece5c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/graphql/tracing/sentry_trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions spec/graphql/tracing/sentry_trace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,25 @@ 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

before do
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
Expand Down

0 comments on commit 8ece5c3

Please sign in to comment.