Module: ActiveShopifyGraphQL::Logging::GraphqlRuntime

Defined in:
lib/active_shopify_graphql/logging/graphql_runtime.rb

Overview

Thread-safe runtime and cost tracking for request summaries Pattern borrowed from ActiveRecord's RuntimeRegistry

Class Method Summary collapse

Class Method Details

.add(duration_ms:, cost:) ⇒ Object



38
39
40
41
# File 'lib/active_shopify_graphql/logging/graphql_runtime.rb', line 38

def add(duration_ms:, cost:)
  self.runtime += duration_ms
  self.cost += cost if cost
end

.costObject



28
29
30
# File 'lib/active_shopify_graphql/logging/graphql_runtime.rb', line 28

def cost
  Thread.current[:active_shopify_graphql_cost] ||= 0
end

.cost=(value) ⇒ Object



24
25
26
# File 'lib/active_shopify_graphql/logging/graphql_runtime.rb', line 24

def cost=(value)
  Thread.current[:active_shopify_graphql_cost] = value
end

.reset_costObject



32
33
34
35
36
# File 'lib/active_shopify_graphql/logging/graphql_runtime.rb', line 32

def reset_cost
  c = cost
  self.cost = 0
  c
end

.reset_runtimeObject



18
19
20
21
22
# File 'lib/active_shopify_graphql/logging/graphql_runtime.rb', line 18

def reset_runtime
  rt = runtime
  self.runtime = 0
  rt
end

.runtimeObject



14
15
16
# File 'lib/active_shopify_graphql/logging/graphql_runtime.rb', line 14

def runtime
  Thread.current[:active_shopify_graphql_runtime] ||= 0
end

.runtime=(value) ⇒ Object



10
11
12
# File 'lib/active_shopify_graphql/logging/graphql_runtime.rb', line 10

def runtime=(value)
  Thread.current[:active_shopify_graphql_runtime] = value
end