rmosolgo/graphql-ruby

Incompatible tracers (PrometheusTrace & SentryTrace)

Alex-Whyatt opened this issue · 1 comments

Describe the bug

When trying to use multiple tracers we're getting a NoMethodError - possibly because there's unique intrument_execution methods in each, but I can't work out the exact cause. It looks to me like the methods might be overriding each other.

Versions

graphql version: 2.3.3
rails (or other framework): 7.1
graphql-batch: 0.6.0

GraphQL schema

class ApiSchema < GraphQL::Schema
  trace_with(GraphQL::Tracing::PrometheusTrace)
  use(GraphQL::Batch)
  use(GraphQL::Subscriptions::ActionCableSubscriptions, broadcast: true)

  trace_with(GraphQL::Tracing::SentryTrace, set_transaction_name: true)

GraphQL query

Example GraphQL query and response (if query execution is involved)

(It's pretty much every execute_multiplex from what I can see)

Steps to reproduce

  1. Use the above tracers (prometheus and sentry)
  2. Get a nice multiplex query from presumably a few grouped normal gql queries
  3. 500 error

Expected behavior

Use multiple tracers with no conflicts. Each work on their own.

Actual behavior

What specifically went wrong?

Place full backtrace here (if a Ruby exception is involved):

Click to view exception backtrace

"name":"Rails","exception":{"name":"NoMethodError","message":"undefined method `key?' for nil","stack_trace":[
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/sentry_trace.rb:91:in `block in instrument_execution'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry/hub.rb:109:in `block in with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry/span.rb:211:in `with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry/hub.rb:107:in `with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry-ruby.rb:490:in `with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/sentry_trace.rb:83:in `instrument_execution'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/prometheus_trace.rb:27:in `execute_query'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/sentry_trace.rb:23:in `block in execute_query'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/sentry_trace.rb:84:in `block in instrument_execution'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry/hub.rb:109:in `block in with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry/span.rb:211:in `with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry/hub.rb:107:in `with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry-ruby.rb:490:in `with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/sentry_trace.rb:83:in `instrument_execution'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/sentry_trace.rb:23:in `execute_query'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/execution/interpreter.rb:69:in `block (3 levels) in run_all'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/dataloader/null_dataloader.rb:19:in `append_job'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/execution/interpreter.rb:57:in `block (2 levels) in run_all'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/execution/interpreter.rb:53:in `each'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/execution/interpreter.rb:53:in `each_with_index'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/execution/interpreter.rb:53:in `block in run_all'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/trace.rb:40:in `execute_multiplex'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/prometheus_trace.rb:27:in `block in execute_multiplex'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/sentry_trace.rb:84:in `block in instrument_execution'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry/hub.rb:109:in `block in with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry/span.rb:211:in `with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry/hub.rb:107:in `with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.17.3/lib/sentry-ruby.rb:490:in `with_child_span'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/sentry_trace.rb:83:in `instrument_execution'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-2.3.3/lib/graphql/tracing/prometheus_trace.rb:27:in `execute_multiplex'",
"/srv/api/vendor/bundle/ruby/3.3.0/gems/graphql-batch-0.6.0/lib/graphql/batch/setup_multiplex.rb:24:in `execute_multiplex'

Additional context

Hey, thanks for the detailed report! Yes, I think you're right that those methods are conflicting. I opened #4957 to address this.