graphql 2.4.13 → 2.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/graphql/analysis/query_complexity.rb +87 -7
- data/lib/graphql/backtrace/table.rb +37 -14
- data/lib/graphql/current.rb +1 -1
- data/lib/graphql/dashboard/detailed_traces.rb +47 -0
- data/lib/graphql/dashboard/installable.rb +22 -0
- data/lib/graphql/dashboard/limiters.rb +93 -0
- data/lib/graphql/dashboard/operation_store.rb +199 -0
- data/lib/graphql/dashboard/statics/charts.min.css +1 -0
- data/lib/graphql/dashboard/statics/dashboard.css +27 -0
- data/lib/graphql/dashboard/statics/dashboard.js +74 -9
- data/lib/graphql/dashboard/subscriptions.rb +96 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/detailed_traces/traces/index.html.erb +45 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/limiters/limiters/show.html.erb +62 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/not_installed.html.erb +18 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/clients/_form.html.erb +23 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/clients/edit.html.erb +21 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/clients/index.html.erb +69 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/clients/new.html.erb +7 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/index_entries/index.html.erb +39 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/index_entries/show.html.erb +32 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/operations/index.html.erb +81 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/operation_store/operations/show.html.erb +71 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/subscriptions/subscriptions/show.html.erb +41 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/subscriptions/topics/index.html.erb +55 -0
- data/lib/graphql/dashboard/views/graphql/dashboard/subscriptions/topics/show.html.erb +40 -0
- data/lib/graphql/dashboard/views/layouts/graphql/dashboard/application.html.erb +49 -1
- data/lib/graphql/dashboard.rb +45 -29
- data/lib/graphql/dataloader/active_record_association_source.rb +28 -8
- data/lib/graphql/dataloader/active_record_source.rb +26 -5
- data/lib/graphql/dataloader/null_dataloader.rb +7 -0
- data/lib/graphql/dataloader/source.rb +16 -4
- data/lib/graphql/dig.rb +2 -1
- data/lib/graphql/execution/interpreter/resolve.rb +3 -3
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +34 -1
- data/lib/graphql/execution/interpreter/runtime.rb +163 -59
- data/lib/graphql/execution/interpreter.rb +5 -13
- data/lib/graphql/execution/multiplex.rb +6 -1
- data/lib/graphql/invalid_null_error.rb +15 -2
- data/lib/graphql/language/lexer.rb +9 -2
- data/lib/graphql/language/nodes.rb +5 -1
- data/lib/graphql/language/parser.rb +14 -6
- data/lib/graphql/query/context.rb +3 -8
- data/lib/graphql/query/partial.rb +179 -0
- data/lib/graphql/query.rb +59 -55
- data/lib/graphql/schema/addition.rb +3 -1
- data/lib/graphql/schema/always_visible.rb +1 -0
- data/lib/graphql/schema/argument.rb +9 -3
- data/lib/graphql/schema/build_from_definition.rb +96 -47
- data/lib/graphql/schema/directive/flagged.rb +2 -0
- data/lib/graphql/schema/directive.rb +33 -1
- data/lib/graphql/schema/field.rb +23 -1
- data/lib/graphql/schema/input_object.rb +38 -30
- data/lib/graphql/schema/list.rb +1 -1
- data/lib/graphql/schema/member/has_arguments.rb +2 -2
- data/lib/graphql/schema/member/has_dataloader.rb +4 -2
- data/lib/graphql/schema/member/has_deprecation_reason.rb +15 -0
- data/lib/graphql/schema/member/has_interfaces.rb +2 -2
- data/lib/graphql/schema/member/type_system_helpers.rb +16 -2
- data/lib/graphql/schema/ractor_shareable.rb +79 -0
- data/lib/graphql/schema/resolver.rb +1 -0
- data/lib/graphql/schema/scalar.rb +1 -6
- data/lib/graphql/schema/timeout.rb +19 -2
- data/lib/graphql/schema/validator/required_validator.rb +15 -6
- data/lib/graphql/schema/visibility/migration.rb +2 -2
- data/lib/graphql/schema/visibility/profile.rb +107 -21
- data/lib/graphql/schema/visibility.rb +41 -29
- data/lib/graphql/schema/warden.rb +13 -5
- data/lib/graphql/schema.rb +228 -32
- data/lib/graphql/static_validation/all_rules.rb +2 -2
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +47 -13
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +78 -16
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +10 -2
- data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +25 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +26 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +6 -2
- data/lib/graphql/testing/helpers.rb +5 -2
- data/lib/graphql/tracing/active_support_notifications_trace.rb +7 -0
- data/lib/graphql/tracing/appoptics_tracing.rb +5 -0
- data/lib/graphql/tracing/appsignal_trace.rb +26 -61
- data/lib/graphql/tracing/data_dog_trace.rb +41 -164
- data/lib/graphql/tracing/monitor_trace.rb +283 -0
- data/lib/graphql/tracing/new_relic_trace.rb +34 -164
- data/lib/graphql/tracing/notifications_trace.rb +183 -37
- data/lib/graphql/tracing/null_trace.rb +1 -1
- data/lib/graphql/tracing/perfetto_trace.rb +16 -19
- data/lib/graphql/tracing/prometheus_trace.rb +47 -74
- data/lib/graphql/tracing/scout_trace.rb +25 -59
- data/lib/graphql/tracing/sentry_trace.rb +56 -99
- data/lib/graphql/tracing/statsd_trace.rb +24 -47
- data/lib/graphql/tracing/trace.rb +0 -17
- data/lib/graphql/tracing.rb +1 -0
- data/lib/graphql/type_kinds.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +1 -1
- metadata +35 -26
- data/lib/graphql/dashboard/views/graphql/dashboard/traces/index.html.erb +0 -63
- data/lib/graphql/static_validation/rules/subscription_root_exists.rb +0 -17
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module StaticValidation
|
4
|
+
module SubscriptionRootExistsAndSingleSubscriptionSelection
|
5
|
+
def on_operation_definition(node, parent)
|
6
|
+
if node.operation_type == "subscription"
|
7
|
+
if context.types.subscription_root.nil?
|
8
|
+
add_error(GraphQL::StaticValidation::SubscriptionRootExistsError.new(
|
9
|
+
'Schema is not configured for subscriptions',
|
10
|
+
nodes: node
|
11
|
+
))
|
12
|
+
elsif node.selections.size != 1
|
13
|
+
add_error(GraphQL::StaticValidation::NotSingleSubscriptionError.new(
|
14
|
+
'A subscription operation may only have one selection',
|
15
|
+
nodes: node,
|
16
|
+
))
|
17
|
+
else
|
18
|
+
super
|
19
|
+
end
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -19,13 +19,17 @@ module GraphQL
|
|
19
19
|
:on_field,
|
20
20
|
]
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
VALIDATE_DIRECTIVE_LOCATION_ON_NODE = <<~RUBY
|
23
|
+
def %{method_name}(node, parent)
|
24
24
|
if !node.directives.empty?
|
25
25
|
validate_directive_location(node)
|
26
26
|
end
|
27
27
|
super(node, parent)
|
28
28
|
end
|
29
|
+
RUBY
|
30
|
+
DIRECTIVE_NODE_HOOKS.each do |method_name|
|
31
|
+
# Can't use `define_method {...}` here because the proc can't be isolated for use in non-main Ractors
|
32
|
+
module_eval(VALIDATE_DIRECTIVE_LOCATION_ON_NODE % { method_name: method_name }) # rubocop:disable Development/NoEvalCop
|
29
33
|
end
|
30
34
|
|
31
35
|
private
|
@@ -43,18 +43,21 @@ module GraphQL
|
|
43
43
|
type_name, *field_names = field_path.split(".")
|
44
44
|
dummy_query = GraphQL::Query.new(schema, "{ __typename }", context: context)
|
45
45
|
query_context = dummy_query.context
|
46
|
+
dataloader = query_context.dataloader
|
46
47
|
object_type = dummy_query.types.type(type_name) # rubocop:disable Development/ContextIsPassedCop
|
47
48
|
if object_type
|
48
49
|
graphql_result = object
|
49
50
|
field_names.each do |field_name|
|
50
51
|
inner_object = graphql_result
|
51
|
-
|
52
|
+
dataloader.run_isolated {
|
53
|
+
graphql_result = object_type.wrap(inner_object, query_context)
|
54
|
+
}
|
52
55
|
if graphql_result.nil?
|
53
56
|
return nil
|
54
57
|
end
|
55
58
|
visible_field = dummy_query.types.field(object_type, field_name) # rubocop:disable Development/ContextIsPassedCop
|
56
59
|
if visible_field
|
57
|
-
|
60
|
+
dataloader.run_isolated {
|
58
61
|
query_context[:current_field] = visible_field
|
59
62
|
field_args = visible_field.coerce_arguments(graphql_result, arguments, query_context)
|
60
63
|
field_args = schema.sync_lazy(field_args)
|
@@ -10,6 +10,13 @@ module GraphQL
|
|
10
10
|
# class MySchema < GraphQL::Schema
|
11
11
|
# trace_with(GraphQL::Tracing::ActiveSupportNotificationsTrace)
|
12
12
|
# end
|
13
|
+
#
|
14
|
+
# @example Subscribing to GraphQL events with ActiveSupport::Notifications
|
15
|
+
# ActiveSupport::Notifications.subscribe(/graphql/) do |event|
|
16
|
+
# pp event.name
|
17
|
+
# pp event.payload
|
18
|
+
# end
|
19
|
+
#
|
13
20
|
module ActiveSupportNotificationsTrace
|
14
21
|
include NotificationsTrace
|
15
22
|
def initialize(engine: ActiveSupport::Notifications, **rest)
|
@@ -22,6 +22,11 @@ module GraphQL
|
|
22
22
|
# These GraphQL events will show up as 'graphql.execute' spans
|
23
23
|
EXEC_KEYS = ['execute_multiplex', 'execute_query', 'execute_query_lazy'].freeze
|
24
24
|
|
25
|
+
def initialize(...)
|
26
|
+
warn "GraphQL::Tracing::AppOptics tracing is deprecated; update to SolarWindsAPM instead, which uses OpenTelemetry."
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
25
30
|
# During auto-instrumentation this version of AppOpticsTracing is compared
|
26
31
|
# with the version provided in the appoptics_apm gem, so that the newer
|
27
32
|
# version of the class can be used
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "graphql/tracing/platform_trace"
|
2
|
+
require "graphql/tracing/monitor_trace"
|
4
3
|
|
5
4
|
module GraphQL
|
6
5
|
module Tracing
|
@@ -10,80 +9,46 @@ module GraphQL
|
|
10
9
|
# class MySchema < GraphQL::Schema
|
11
10
|
# trace_with GraphQL::Tracing::AppsignalTrace
|
12
11
|
# end
|
12
|
+
AppsignalTrace = MonitorTrace.create_module("appsignal")
|
13
13
|
module AppsignalTrace
|
14
|
-
include PlatformTrace
|
15
|
-
|
16
14
|
# @param set_action_name [Boolean] If true, the GraphQL operation name will be used as the transaction name.
|
17
15
|
# This is not advised if you run more than one query per HTTP request, for example, with `graphql-client` or multiplexing.
|
18
16
|
# It can also be specified per-query with `context[:set_appsignal_action_name]`.
|
19
17
|
def initialize(set_action_name: false, **rest)
|
20
|
-
|
18
|
+
rest[:set_transaction_name] ||= set_action_name
|
19
|
+
setup_appsignal_monitor(**rest)
|
21
20
|
super
|
22
21
|
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
"analyze_multiplex" => "analyze.graphql",
|
32
|
-
"execute_multiplex" => "execute.graphql",
|
33
|
-
"execute_query" => "execute.graphql",
|
34
|
-
"execute_query_lazy" => "execute.graphql",
|
35
|
-
}.each do |trace_method, platform_key|
|
36
|
-
module_eval <<-RUBY, __FILE__, __LINE__
|
37
|
-
def #{trace_method}(**data)
|
38
|
-
#{
|
39
|
-
if trace_method == "execute_query"
|
40
|
-
<<-RUBY
|
41
|
-
set_this_txn_name = data[:query].context[:set_appsignal_action_name]
|
42
|
-
if set_this_txn_name == true || (set_this_txn_name.nil? && @set_action_name)
|
43
|
-
Appsignal::Transaction.current.set_action(transaction_name(data[:query]))
|
44
|
-
end
|
45
|
-
RUBY
|
46
|
-
end
|
47
|
-
}
|
48
|
-
|
49
|
-
Appsignal.instrument("#{platform_key}") do
|
50
|
-
super
|
23
|
+
class AppsignalMonitor < MonitorTrace::Monitor
|
24
|
+
def instrument(keyword, object)
|
25
|
+
if keyword == :execute
|
26
|
+
query = object.queries.first
|
27
|
+
set_this_txn_name = query.context[:set_appsignal_action_name]
|
28
|
+
if set_this_txn_name == true || (set_this_txn_name.nil? && @set_transaction_name)
|
29
|
+
Appsignal::Transaction.current.set_action(transaction_name(query))
|
51
30
|
end
|
52
31
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
# rubocop:enable Development/NoEvalCop
|
57
|
-
|
58
|
-
def platform_execute_field(platform_key)
|
59
|
-
Appsignal.instrument(platform_key) do
|
60
|
-
yield
|
32
|
+
Appsignal.instrument(name_for(keyword, object)) do
|
33
|
+
yield
|
34
|
+
end
|
61
35
|
end
|
62
|
-
end
|
63
36
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
37
|
+
include MonitorTrace::Monitor::GraphQLSuffixNames
|
38
|
+
class Event < GraphQL::Tracing::MonitorTrace::Monitor::Event
|
39
|
+
def start
|
40
|
+
Appsignal::Transaction.current.start_event
|
41
|
+
end
|
69
42
|
|
70
|
-
|
71
|
-
|
72
|
-
|
43
|
+
def finish
|
44
|
+
Appsignal::Transaction.current.finish_event(
|
45
|
+
@monitor.name_for(@keyword, @object),
|
46
|
+
"",
|
47
|
+
""
|
48
|
+
)
|
49
|
+
end
|
73
50
|
end
|
74
51
|
end
|
75
|
-
|
76
|
-
def platform_field_key(field)
|
77
|
-
"#{field.owner.graphql_name}.#{field.graphql_name}.graphql"
|
78
|
-
end
|
79
|
-
|
80
|
-
def platform_authorized_key(type)
|
81
|
-
"#{type.graphql_name}.authorized.graphql"
|
82
|
-
end
|
83
|
-
|
84
|
-
def platform_resolve_type_key(type)
|
85
|
-
"#{type.graphql_name}.resolve_type.graphql"
|
86
|
-
end
|
87
52
|
end
|
88
53
|
end
|
89
54
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "graphql/tracing/platform_trace"
|
2
|
+
require "graphql/tracing/monitor_trace"
|
4
3
|
|
5
4
|
module GraphQL
|
6
5
|
module Tracing
|
@@ -9,186 +8,64 @@ module GraphQL
|
|
9
8
|
# class MySchema < GraphQL::Schema
|
10
9
|
# trace_with GraphQL::Tracing::DataDogTrace
|
11
10
|
# end
|
11
|
+
# @example Skipping `resolve_type` and `authorized` events
|
12
|
+
# trace_with GraphQL::Tracing::DataDogTrace, trace_authorized: false, trace_resolve_type: false
|
13
|
+
DataDogTrace = MonitorTrace.create_module("datadog")
|
12
14
|
module DataDogTrace
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
class DatadogMonitor < MonitorTrace::Monitor
|
16
|
+
def initialize(set_transaction_name:, service: nil, tracer: nil, **_rest)
|
17
|
+
super
|
18
|
+
if tracer.nil?
|
19
|
+
tracer = defined?(Datadog::Tracing) ? Datadog::Tracing : Datadog.tracer
|
20
|
+
end
|
21
|
+
@tracer = tracer
|
22
|
+
@service_name = service
|
23
|
+
@has_prepare_span = @trace.respond_to?(:prepare_span)
|
19
24
|
end
|
20
|
-
@tracer = tracer
|
21
|
-
|
22
|
-
@analytics_enabled = analytics_enabled
|
23
|
-
@analytics_sample_rate = analytics_sample_rate
|
24
|
-
|
25
|
-
@service_name = service
|
26
|
-
@has_prepare_span = respond_to?(:prepare_span)
|
27
|
-
super
|
28
|
-
end
|
29
|
-
|
30
|
-
# rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
|
31
25
|
|
32
|
-
|
33
|
-
'lex' => 'lex.graphql',
|
34
|
-
'parse' => 'parse.graphql',
|
35
|
-
'validate' => 'validate.graphql',
|
36
|
-
'analyze_query' => 'analyze.graphql',
|
37
|
-
'analyze_multiplex' => 'analyze.graphql',
|
38
|
-
'execute_multiplex' => 'execute.graphql',
|
39
|
-
'execute_query' => 'execute.graphql',
|
40
|
-
'execute_query_lazy' => 'execute.graphql',
|
41
|
-
}.each do |trace_method, trace_key|
|
42
|
-
module_eval <<-RUBY, __FILE__, __LINE__
|
43
|
-
def #{trace_method}(**data)
|
44
|
-
@tracer.trace("#{trace_key}", service: @service_name, type: 'custom') do |span|
|
45
|
-
span.set_tag('component', 'graphql')
|
46
|
-
span.set_tag('operation', '#{trace_method}')
|
26
|
+
attr_reader :tracer, :service_name
|
47
27
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
span.set_metric('_dd1.sr.eausr', @analytics_sample_rate) if @analytics_enabled
|
63
|
-
RUBY
|
64
|
-
elsif trace_method == 'execute_query'
|
65
|
-
<<-RUBY
|
66
|
-
span.set_tag(:selected_operation_name, data[:query].selected_operation_name)
|
67
|
-
span.set_tag(:selected_operation_type, data[:query].selected_operation.operation_type)
|
68
|
-
span.set_tag(:query_string, data[:query].query_string)
|
69
|
-
RUBY
|
70
|
-
end
|
71
|
-
}
|
72
|
-
if @has_prepare_span
|
73
|
-
prepare_span("#{trace_method.sub("platform_", "")}", data, span)
|
28
|
+
def instrument(keyword, object)
|
29
|
+
trace_key = name_for(keyword, object)
|
30
|
+
@tracer.trace(trace_key, service: @service_name, type: 'custom') do |span|
|
31
|
+
span.set_tag('component', 'graphql')
|
32
|
+
op_name = keyword.respond_to?(:name) ? keyword.name : keyword.to_s
|
33
|
+
span.set_tag('operation', op_name)
|
34
|
+
|
35
|
+
if keyword == :execute
|
36
|
+
operations = object.queries.map(&:selected_operation_name).join(', ')
|
37
|
+
first_query = object.queries.first
|
38
|
+
resource = if operations.empty?
|
39
|
+
fallback_transaction_name(first_query && first_query.context)
|
40
|
+
else
|
41
|
+
operations
|
74
42
|
end
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
78
|
-
RUBY
|
79
|
-
end
|
43
|
+
span.resource = resource if resource
|
80
44
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
trace_field = if return_type.kind.scalar? || return_type.kind.enum?
|
86
|
-
(field.trace.nil? && @trace_scalars) || field.trace
|
87
|
-
else
|
88
|
-
true
|
89
|
-
end
|
90
|
-
platform_key = if trace_field
|
91
|
-
@platform_key_cache[DataDogTrace].platform_field_key_cache[field]
|
92
|
-
else
|
93
|
-
nil
|
94
|
-
end
|
95
|
-
if platform_key && trace_field
|
96
|
-
@tracer.trace(platform_key, service: @service_name, type: 'custom') do |span|
|
97
|
-
span.set_tag('component', 'graphql')
|
98
|
-
span.set_tag('operation', span_key)
|
45
|
+
span.set_tag("selected_operation_name", first_query.selected_operation_name)
|
46
|
+
span.set_tag("selected_operation_type", first_query.selected_operation&.operation_type)
|
47
|
+
span.set_tag("query_string", first_query.query_string)
|
48
|
+
end
|
99
49
|
|
100
50
|
if @has_prepare_span
|
101
|
-
|
102
|
-
prepare_span(span_key, prepare_span_data, span)
|
51
|
+
@trace.prepare_span(keyword, object, span)
|
103
52
|
end
|
104
53
|
yield
|
105
54
|
end
|
106
|
-
else
|
107
|
-
yield
|
108
|
-
end
|
109
|
-
end
|
110
|
-
def execute_field(query:, field:, ast_node:, arguments:, object:)
|
111
|
-
execute_field_span("execute_field", query, field, ast_node, arguments, object) do
|
112
|
-
super(query: query, field: field, ast_node: ast_node, arguments: arguments, object: object)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def execute_field_lazy(query:, field:, ast_node:, arguments:, object:)
|
117
|
-
execute_field_span("execute_field_lazy", query, field, ast_node, arguments, object) do
|
118
|
-
super(query: query, field: field, ast_node: ast_node, arguments: arguments, object: object)
|
119
55
|
end
|
120
|
-
end
|
121
56
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
def authorized_span(span_key, object, type, query)
|
129
|
-
platform_key = @platform_key_cache[DataDogTrace].platform_authorized_key_cache[type]
|
130
|
-
@tracer.trace(platform_key, service: @service_name, type: 'custom') do |span|
|
131
|
-
span.set_tag('component', 'graphql')
|
132
|
-
span.set_tag('operation', span_key)
|
133
|
-
|
134
|
-
if @has_prepare_span
|
135
|
-
prepare_span(span_key, {object: object, type: type, query: query}, span)
|
57
|
+
include MonitorTrace::Monitor::GraphQLSuffixNames
|
58
|
+
class Event < MonitorTrace::Monitor::Event
|
59
|
+
def start
|
60
|
+
name = @monitor.name_for(keyword, object)
|
61
|
+
@dd_span = @monitor.tracer.trace(name, service: @monitor.service_name, type: 'custom')
|
136
62
|
end
|
137
|
-
yield
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def authorized_lazy(object:, type:, query:)
|
142
|
-
authorized_span("authorized_lazy", object, type, query) do
|
143
|
-
super(query: query, type: type, object: object)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def resolve_type(object:, type:, query:)
|
148
|
-
resolve_type_span("resolve_type", object, type, query) do
|
149
|
-
super(object: object, query: query, type: type)
|
150
|
-
end
|
151
|
-
end
|
152
63
|
|
153
|
-
|
154
|
-
|
155
|
-
super(object: object, query: query, type: type)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def resolve_type_span(span_key, object, type, query)
|
160
|
-
platform_key = @platform_key_cache[DataDogTrace].platform_resolve_type_key_cache[type]
|
161
|
-
@tracer.trace(platform_key, service: @service_name, type: 'custom') do |span|
|
162
|
-
span.set_tag('component', 'graphql')
|
163
|
-
span.set_tag('operation', span_key)
|
164
|
-
|
165
|
-
if @has_prepare_span
|
166
|
-
prepare_span(span_key, {object: object, type: type, query: query}, span)
|
64
|
+
def finish
|
65
|
+
@dd_span.finish
|
167
66
|
end
|
168
|
-
yield
|
169
67
|
end
|
170
68
|
end
|
171
|
-
|
172
|
-
include PlatformTrace
|
173
|
-
|
174
|
-
# Implement this method in a subclass to apply custom tags to datadog spans
|
175
|
-
# @param key [String] The event being traced
|
176
|
-
# @param data [Hash] The runtime data for this event (@see GraphQL::Tracing for keys for each event)
|
177
|
-
# @param span [Datadog::Tracing::SpanOperation] The datadog span for this event
|
178
|
-
# def prepare_span(key, data, span)
|
179
|
-
# end
|
180
|
-
|
181
|
-
def platform_field_key(field)
|
182
|
-
field.path
|
183
|
-
end
|
184
|
-
|
185
|
-
def platform_authorized_key(type)
|
186
|
-
"#{type.graphql_name}.authorized"
|
187
|
-
end
|
188
|
-
|
189
|
-
def platform_resolve_type_key(type)
|
190
|
-
"#{type.graphql_name}.resolve_type"
|
191
|
-
end
|
192
69
|
end
|
193
70
|
end
|
194
71
|
end
|