-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trace_mode(:foo, TraceClass)
does not stick for child classes
#4632
Comments
Hi! Thanks for the detailed report. In short, I agree that it should work that way -- I'll take a look soon! Hopefully some more digging around between modules and superclasses will make it work. |
Ok, I copied your test and tried a few things to fix it, and yeah, I think we'll need a different approach for your use case. What about approaching it differently, so you added the slow-ish tracing to a named mode: trace_with SlowInstrumentation, mode: :full_instrumentation Then, when executing, you could use the context = {
trace_mode: performance_sensitive? ? :default : :full_instrumentation
} That's a little clunky, would supporting a custom |
I think that would work: most schemas would have |
I added some support for this in #4642. One tradeoff I made was to handle
In effect, this creates isolated inheritance chains, where a manually added trace class (that is, added with But I think that's desirable in this case, right? And I don't think it should cause hiccups in the future -- |
I think so too – that's exactly what I was trying to achieve. Thanks for looking into this Robert 🙇. |
Describe the bug
Overriding a schema's trace class for a particular mode does not stick for child classes.
Extracted from this failing test:
Versions
graphql
version: 2781f4f (master as of writing)Additional context
I don't know if it's an actual bug, or I'm calling code I shouldn't call. My use case is to opt-out of all default traces for performance-sensitive scenarios. It works if I redefine the trace class on each schema subclasses. For now, I've gotten around this issue by using the schema's
inherited
hook and re-callingtrace_mode
the subclasses.I tried fixing it with:
but that caused default traces to not be added to the mode-specific trace classes as pointed out by this assertion:
graphql-ruby/spec/graphql/tracing/trace_modes_spec.rb
Line 82 in d3f38f5
The text was updated successfully, but these errors were encountered: