-
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
Add a Rails::Engine-based dashboard with trace viewer #5244
Conversation
@@ -125,6 +125,9 @@ class << self | |||
autoload :LoadApplicationObjectFailedError, "graphql/load_application_object_failed_error" | |||
autoload :Testing, "graphql/testing" | |||
autoload :Current, "graphql/current" | |||
if defined?(::Rails::Engine) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module GraphQL missing tests for lines 15, 16, 17, 18, 63, 67, 68, 72, 128, 128, 128 (coverage: 0.88)
# @return [Boolean] When `true`, save a detailed trace for this query. | ||
# @see Tracing::DetailedTrace DetailedTrace saves traces when this method returns true | ||
def detailed_trace?(query) | ||
raise "#{self} must implement `def.detailed_trace?(query)` to use DetailedTrace. Implement this method in your schema definition." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance method detailed_trace? missing tests for line 1376 (coverage: 0.0)
target = options[:query] || options[:multiplex] | ||
mode ||= target && target.context[:trace_mode] | ||
should_sample = if detailed_trace | ||
if (query = options[:query]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance method new_trace missing tests for lines 1469, 1470, 1471, 1475, 1469, 1470, 1471, 1471, 1474 (coverage: 0.75)
# @param redis [Redis] If provided, profiles will be stored in Redis for later review | ||
# @param limit [Integer] A maximum number of profiles to store | ||
def self.use(schema, trace_mode: :profile_sample, memory: false, redis: nil, limit: nil) | ||
storage = if redis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class method use missing tests for lines 34, 35, 34, 35 (coverage: 0.75)
end | ||
|
||
def traces(last:, before:) | ||
before = case before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance method traces missing tests for lines 15, 15 (coverage: 0.875)
target = options[:query] || options[:multiplex] | ||
mode ||= target && target.context[:trace_mode] | ||
should_sample = if detailed_trace | ||
if (query = options[:query]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance method new_trace missing tests for lines 1469, 1470, 1471, 1469, 1470, 1471, 1471 (coverage: 0.85)
I've been working on a detailed query tracer which produces artifacts for Perfetto (https://perfetto.dev). In this PR I'm going to:
GraphQL::Dashboard
, which is a Rails enginePerfettoTrace
so that traces can be saved for later (Redis and ActiveRecord)Why a Rails Engine? I've seen it done nicely, eg https://github.com/bensheldon/good_job, https://github.com/mbajur/inner_performance. I have rolled my own in
GraphQL::Pro::Dashboard
for a long time but I'm not sure it's worth it. I think everyone uses Rails, and an Engine will bring a lot of convenience in development, robustness in production, lots of configuration options. If you're not using Rails, I think you could spin up a sidecar app just for running the dashboard if you need to.I plan to replace
GraphQL::Pro::Dashboard
with this one (rolling its features into this one).TODO: