Class: GraphQLMetrics::TimedBatchExecutor
- Inherits:
-
BASE_CLASS
- Object
- GraphQLMetrics::TimedBatchExecutor
- Defined in:
- lib/graphql_metrics/timed_batch_executor.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.clear_timings ⇒ Object
31 32 33 |
# File 'lib/graphql_metrics/timed_batch_executor.rb', line 31 def clear_timings TIMINGS.clear end |
.serialize_loader_key(loader_key) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/graphql_metrics/timed_batch_executor.rb', line 35 def serialize_loader_key(loader_key) identifiers = [] serialized = loader_key.map do |group_arg| if [Class, Symbol, String].include?(group_arg.class) group_arg elsif group_arg.is_a?(Numeric) identifiers << group_arg '_' elsif group_arg.respond_to?(:id) identifiers << group_arg.id "#{group_arg.class}/_" else '?' end end [serialized.map(&:to_s).join('/'), identifiers.map(&:to_s)] end |
.timings ⇒ Object
27 28 29 |
# File 'lib/graphql_metrics/timed_batch_executor.rb', line 27 def timings TIMINGS end |
Instance Method Details
#around_promise_callbacks ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/graphql_metrics/timed_batch_executor.rb', line 66 def around_promise_callbacks return super unless end_time = Instrumentation.current_time TIMINGS[[:current_loader].loader_key] ||= { times: [], perform_queue_sizes: [] } TIMINGS[[:current_loader].loader_key][:times] << end_time - [:start_time] TIMINGS[[:current_loader].loader_key][:perform_queue_sizes] << [:perform_queue_sizes] = nil super end |
#resolve(loader) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/graphql_metrics/timed_batch_executor.rb', line 56 def resolve(loader) = { start_time: Instrumentation.current_time, current_loader: loader, perform_queue_sizes: loader.send(:queue).size } super end |