Consolidate instrument(:query | :multiplex, ...)
into trace modules, deprecate instrument
#4771
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an old instrumentation API which is redundant with trace modules. But it has been used a long time, so it's out there.
Removing this from the execution code removes 9 (🎉 🙄 ) objects per query
TODO:
Add docs about handling errors in trace methodsI think these migration notes will do the job.Migration notes
In general,
before_query
andafter_query
should be done indef execute_multiplex
. That gives you better control becausemultiplex.queries
haven't actually started execution yet (so you can still change their initial parameters) and you can manually handle errors usingrescue
.Instrumentation had the following error handling rule:
You can implement that using
rescue
in Ruby:In that way, an error in
do_something_instrumenty
would preventdo_something_after_execution
from being called, but an error further down the stack (duringsuper
) would not preventdo_something_after_execution
from being called.The old
before_
/after_
hooks can be implemented on top of a trace module, see:graphql-ruby/lib/graphql/tracing/legacy_hooks_trace.rb
Line 4 in 9567ba4
You could copy that into your app, or better yet, open an issue on this repo and let's see how
trace_with
could handle it.