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, StatsdTracing
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.
- #trace(key, data) ⇒ 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.
19 20 21 22 23 |
# File 'lib/graphql/tracing/platform_tracing.rb', line 19 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.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/graphql/tracing/platform_tracing.rb', line 75 def self.use(schema_defn, = {}) if [:legacy_tracing] tracer = self.new(**) schema_defn.tracer(tracer) else tracing_name = self.name.split("::").last trace_name = tracing_name.sub("Tracing", "Trace") if GraphQL::Tracing.const_defined?(trace_name, false) trace_module = GraphQL::Tracing.const_get(trace_name) warn("`use(#{self.name})` is deprecated, use the equivalent `trace_with(#{trace_module.name})` instead. More info: https://graphql-ruby.org/queries/tracing.html") schema_defn.trace_with(trace_module, **) else warn("`use(#{self.name})` and `Tracing::PlatformTracing` are deprecated. Use a `trace_with(...)` module instead. More info: https://graphql-ruby.org/queries/tracing.html. Please open an issue on the GraphQL-Ruby repo if you want to discuss further!") tracer = self.new(**) schema_defn.tracer(tracer, silence_deprecation_warning: true) end end end |
Instance Method Details
#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.
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 |
# File 'lib/graphql/tracing/platform_tracing.rb', line 25 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" field = data[:field] 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 platform_key = if trace_field context = data.fetch(:query).context cached_platform_key(context, field, :field) { platform_field_key(field.owner, field) } else nil end if platform_key && trace_field platform_trace(platform_key, key, data) do yield end else yield end when "authorized", "authorized_lazy" type = data.fetch(:type) context = data.fetch(:context) platform_key = cached_platform_key(context, type, :authorized) { (type) } platform_trace(platform_key, key, data) do yield end when "resolve_type", "resolve_type_lazy" type = data.fetch(:type) context = data.fetch(:context) platform_key = cached_platform_key(context, type, :resolve_type) { platform_resolve_type_key(type) } platform_trace(platform_key, key, data) do yield end else # it's a custom key yield end end |