Class: GraphQL::Tracing::PlatformTracing Private
- Inherits:
-
Object
- Object
- GraphQL::Tracing::PlatformTracing
- Defined in:
- lib/graphql/tracing/platform_tracing.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Each platform provides:
- .platform_keys
- #platform_trace
- #platform_field_key(type, field)
Direct Known Subclasses
AppOpticsTracing, AppsignalTracing, DataDogTracing, NewRelicTracing, PrometheusTracing, ScoutTracing, SkylightTracing
Class Attribute Summary collapse
-
.platform_keys ⇒ Object
private
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PlatformTracing
constructor
private
A new instance of PlatformTracing.
-
#instrument(type, field) ⇒ Object
private
-
#trace(key, data) ⇒ Object
private
-
#trace_field(type, field) ⇒ Object
private
Constructor Details
#initialize(options = {}) ⇒ PlatformTracing
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of PlatformTracing.
15 16 17 18 19 |
# File 'lib/graphql/tracing/platform_tracing.rb', line 15 def initialize( = {}) @options = @platform_keys = self.class.platform_keys @trace_scalars = .fetch(:trace_scalars, false) end |
Class Attribute Details
.platform_keys ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/graphql/tracing/platform_tracing.rb', line 12 def platform_keys @platform_keys end |
Class Method Details
.use(schema_defn, options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
99 100 101 102 103 |
# File 'lib/graphql/tracing/platform_tracing.rb', line 99 def self.use(schema_defn, = {}) tracer = self.new() schema_defn.instrument(:field, tracer) schema_defn.tracer(tracer) end |
Instance Method Details
#instrument(type, field) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/graphql/tracing/platform_tracing.rb', line 79 def instrument(type, field) return_type = field.type.unwrap case return_type when GraphQL::ScalarType, GraphQL::EnumType if field.trace || (field.trace.nil? && @trace_scalars) trace_field(type, field) else field end else trace_field(type, field) end end |
#trace(key, data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/graphql/tracing/platform_tracing.rb', line 21 def trace(key, data) case key when "lex", "parse", "validate", "analyze_query", "analyze_multiplex", "execute_query", "execute_query_lazy", "execute_multiplex" platform_key = @platform_keys.fetch(key) platform_trace(platform_key, key, data) do yield end when "execute_field", "execute_field_lazy" if data[:context] field = data[:context].field platform_key = field.[:platform_key] trace_field = true # implemented with instrumenter else field = data[:field] cache = platform_key_cache(data.fetch(:query).context) platform_key = cache.fetch(field) do cache[field] = platform_field_key(data[:owner], field) end return_type = field.type.unwrap trace_field = if return_type.kind.scalar? || return_type.kind.enum? (field.trace.nil? && @trace_scalars) || field.trace else true end end if platform_key && trace_field platform_trace(platform_key, key, data) do yield end else yield end when "authorized", "authorized_lazy" cache = platform_key_cache(data.fetch(:context)) type = data.fetch(:type) platform_key = cache.fetch(type) do cache[type] = (type) end platform_trace(platform_key, key, data) do yield end when "resolve_type", "resolve_type_lazy" cache = platform_key_cache(data.fetch(:context)) type = data.fetch(:type) platform_key = cache.fetch(type) do cache[type] = platform_resolve_type_key(type) end platform_trace(platform_key, key, data) do yield end else # it's a custom key yield end end |
#trace_field(type, field) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
93 94 95 96 97 |
# File 'lib/graphql/tracing/platform_tracing.rb', line 93 def trace_field(type, field) new_f = field.redefine new_f.[:platform_key] = platform_field_key(type, field) new_f end |