Skip to content

Skip tracing correctly when query is being retried. #90

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/graphql/metrics/trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ def parse(query_string:)
end

def validate(query:, validate:)
return super if @skip_tracing
return super if skip_tracing_for_query?(query:)
capture_validation_time(query.context) { super }
end

def analyze_query(query:)
return super if @skip_tracing
return super if skip_tracing_for_query?(query:)
capture_analysis_time(query.context) { super }
end

def execute_query(query:)
return super if @skip_tracing
return super if skip_tracing_for_query?(query:)
capture_query_start_time(query.context) { super }
end

def execute_field(field:, query:, ast_node:, arguments:, object:)
return super if @skip_tracing || query.context[SKIP_FIELD_AND_ARGUMENT_METRICS]
return super if skip_tracing_for_query?(query:) || query.context[SKIP_FIELD_AND_ARGUMENT_METRICS]
return super unless capture_field_timings?(query.context)
trace_field(GraphQL::Metrics::INLINE_FIELD_TIMINGS, query) { super }
end

def execute_field_lazy(field:, query:, ast_node:, arguments:, object:)
return super if @skip_tracing || query.context[SKIP_FIELD_AND_ARGUMENT_METRICS]
return super if skip_tracing_for_query?(query:) || query.context[SKIP_FIELD_AND_ARGUMENT_METRICS]
return super unless capture_field_timings?(query.context)
trace_field(GraphQL::Metrics::LAZY_FIELD_TIMINGS, query) { super }
end
Expand Down Expand Up @@ -120,6 +120,10 @@ def trace_field(context_key, query)

result
end

def skip_tracing_for_query?(query:)
@skip_tracing || query.context&.fetch(SKIP_GRAPHQL_METRICS_ANALYSIS, false)
end
end
end
end
Loading