class Yabeda::GraphQL::Instrumentation

Public Instance Methods

after_query(query) click to toggle source
# File lib/yabeda/graphql/instrumentation.rb, line 8
def after_query(query)
  cache(query).each do |_path, options|
    Yabeda.graphql.field_resolve_runtime.measure(options[:tags], options[:duration])
    Yabeda.graphql.fields_request_count.increment(options[:tags])
  end
end
before_query(query) click to toggle source
# File lib/yabeda/graphql/instrumentation.rb, line 4
def before_query(query)
  reset_cache!(query)
end

Private Instance Methods

cache(query) click to toggle source
# File lib/yabeda/graphql/instrumentation.rb, line 17
def cache(query)
  query.context.namespace(Yabeda::GraphQL)[:field_call_cache]
end
reset_cache!(query) click to toggle source
# File lib/yabeda/graphql/instrumentation.rb, line 21
def reset_cache!(query)
  query.context.namespace(Yabeda::GraphQL)[:field_call_cache] =
    Hash.new { |h,k| h[k] = { tags: {}, duration: 0.0 } }
end