Class: GraphQL::Tracing::DataDogTracing
Instance Method Summary
collapse
#initialize, #instrument, #trace, #trace_field, use
Instance Method Details
#analytics_available? ⇒ Boolean
49
50
51
52
53
|
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 49
def analytics_available?
defined?(Datadog::Contrib::Analytics) \
&& Datadog::Contrib::Analytics.respond_to?(:enabled?) \
&& Datadog::Contrib::Analytics.respond_to?(:set_sample_rate)
end
|
#analytics_enabled? ⇒ Boolean
55
56
57
|
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 55
def analytics_enabled?
analytics_available? && Datadog::Contrib::Analytics.enabled?(options.fetch(:analytics_enabled, false))
end
|
#analytics_sample_rate ⇒ Object
59
60
61
|
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 59
def analytics_sample_rate
options.fetch(:analytics_sample_rate, 1.0)
end
|
67
68
69
|
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 67
def platform_authorized_key(type)
"#{type.graphql_name}.authorized"
end
|
63
64
65
|
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 63
def platform_field_key(type, field)
"#{type.graphql_name}.#{field.graphql_name}"
end
|
71
72
73
|
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 71
def platform_resolve_type_key(type)
"#{type.graphql_name}.resolve_type"
end
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 17
def platform_trace(platform_key, key, data)
tracer.trace(platform_key, service: service_name) do |span|
span.span_type = 'custom'
if key == 'execute_multiplex'
operations = data[:multiplex].queries.map(&:selected_operation_name).join(', ')
span.resource = operations unless operations.empty?
if analytics_enabled?
Datadog::Contrib::Analytics.set_sample_rate(span, analytics_sample_rate)
end
end
if key == 'execute_query'
span.set_tag(:selected_operation_name, data[:query].selected_operation_name)
span.set_tag(:selected_operation_type, data[:query].selected_operation.operation_type)
span.set_tag(:query_string, data[:query].query_string)
end
yield
end
end
|
#service_name ⇒ Object
41
42
43
|
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 41
def service_name
options.fetch(:service, 'ruby-graphql')
end
|
#tracer ⇒ Object
45
46
47
|
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 45
def tracer
options.fetch(:tracer, Datadog.tracer)
end
|