class GraphQL::Tracing::DataDogTracing
Public Instance Methods
analytics_available?()
click to toggle source
# File lib/graphql/tracing/data_dog_tracing.rb, line 71 def analytics_available? defined?(Datadog::Contrib::Analytics) \ && Datadog::Contrib::Analytics.respond_to?(:enabled?) \ && Datadog::Contrib::Analytics.respond_to?(:set_sample_rate) end
analytics_enabled?()
click to toggle source
# File lib/graphql/tracing/data_dog_tracing.rb, line 77 def analytics_enabled? analytics_available? && Datadog::Contrib::Analytics.enabled?(options.fetch(:analytics_enabled, false)) end
analytics_sample_rate()
click to toggle source
# File lib/graphql/tracing/data_dog_tracing.rb, line 81 def analytics_sample_rate options.fetch(:analytics_sample_rate, 1.0) end
platform_field_key(type, field)
click to toggle source
# File lib/graphql/tracing/data_dog_tracing.rb, line 85 def platform_field_key(type, field) "#{type.graphql_name}.#{field.graphql_name}" end
platform_resolve_type_key(type)
click to toggle source
# File lib/graphql/tracing/data_dog_tracing.rb, line 93 def platform_resolve_type_key(type) "#{type.graphql_name}.resolve_type" end
platform_trace(platform_key, key, data) { || ... }
click to toggle source
# 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 defined?(Datadog::Tracing::Metadata::Ext) # Introduced in ddtrace 1.0 span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, 'graphql') span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, key) end if key == 'execute_multiplex' operations = data[:multiplex].queries.map(&:selected_operation_name).join(', ') resource = if operations.empty? first_query = data[:multiplex].queries.first fallback_transaction_name(first_query && first_query.context) else operations end span.resource = resource if resource # For top span of query, set the analytics sample rate tag, if available. 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 prepare_span(key, data, span) yield end end
prepare_span(key, data, span)
click to toggle source
Implement this method in a subclass to apply custom tags to datadog spans @param key [String] The event being traced @param data [Hash] The runtime data for this event (@see GraphQL::Tracing
for keys for each event) @param span [Datadog::Tracing::SpanOperation] The datadog span for this event
# File lib/graphql/tracing/data_dog_tracing.rb, line 62 def prepare_span(key, data, span) end
service_name()
click to toggle source
# File lib/graphql/tracing/data_dog_tracing.rb, line 54 def service_name options.fetch(:service, 'ruby-graphql') end
tracer()
click to toggle source
# File lib/graphql/tracing/data_dog_tracing.rb, line 65 def tracer default_tracer = defined?(Datadog::Tracing) ? Datadog::Tracing : Datadog.tracer options.fetch(:tracer, default_tracer) end