lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb in opentelemetry-instrumentation-graphql-0.26.5 vs lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb in opentelemetry-instrumentation-graphql-0.26.6
- old
+ new
@@ -13,13 +13,13 @@
# GraphQLTrace contains the OpenTelemetry tracer implementation compatible with
# the new GraphQL tracing API (>= 2.0.18)
module GraphQLTrace # rubocop:disable Metrics/ModuleLength
def initialize(trace_scalars: false, **_options)
@trace_scalars = trace_scalars
- @platform_field_key_cache = Hash.new { |h, k| h[k] = platform_field_key(k) }
- @platform_authorized_key_cache = Hash.new { |h, k| h[k] = platform_authorized_key(k) }
- @platform_resolve_type_key_cache = Hash.new { |h, k| h[k] = platform_resolve_type_key(k) }
+ @_otel_field_key_cache = Hash.new { |h, k| h[k] = _otel_field_key(k) }
+ @_otel_authorized_key_cache = Hash.new { |h, k| h[k] = _otel_authorized_key(k) }
+ @_otel_resolve_type_key_cache = Hash.new { |h, k| h[k] = _otel_resolve_type_key(k) }
super
end
def execute_multiplex(multiplex:, &block)
tracer.in_span('graphql.execute_multiplex', &block)
@@ -70,11 +70,11 @@
def execute_query_lazy(query:, multiplex:, &block)
tracer.in_span('graphql.execute_query_lazy', &block)
end
def execute_field(field:, query:, ast_node:, arguments:, object:, &block)
- platform_key = platform_execute_field_key(field: field)
+ platform_key = _otel_execute_field_key(field: field)
return super unless platform_key
attributes = {}
attributes['graphql.field.parent'] = field.owner&.graphql_name
attributes['graphql.field.name'] = field.graphql_name
@@ -82,11 +82,11 @@
tracer.in_span(platform_key, attributes: attributes, &block)
end
def execute_field_lazy(field:, query:, ast_node:, arguments:, object:, &block)
- platform_key = platform_execute_field_key(field: field)
+ platform_key = _otel_execute_field_key(field: field)
return super unless platform_key
attributes = {}
attributes['graphql.field.parent'] = field.owner&.graphql_name
attributes['graphql.field.name'] = field.graphql_name
@@ -94,56 +94,56 @@
tracer.in_span(platform_key, attributes: attributes, &block)
end
def authorized(query:, type:, object:, &block)
- platform_key = @platform_authorized_key_cache[type]
+ platform_key = @_otel_authorized_key_cache[type]
return super unless platform_key
attributes = {}
attributes['graphql.type.name'] = type.graphql_name
attributes['graphql.lazy'] = false
tracer.in_span(platform_key, attributes: attributes, &block)
end
def authorized_lazy(query:, type:, object:, &block)
- platform_key = @platform_authorized_key_cache[type]
+ platform_key = @_otel_authorized_key_cache[type]
return super unless platform_key
attributes = {}
attributes['graphql.type.name'] = type.graphql_name
attributes['graphql.lazy'] = true
tracer.in_span(platform_key, attributes: attributes, &block)
end
def resolve_type(query:, type:, object:, &block)
- platform_key = @platform_resolve_type_key_cache[type]
+ platform_key = @_otel_resolve_type_key_cache[type]
attributes = {}
attributes['graphql.type.name'] = type.graphql_name
attributes['graphql.lazy'] = false
tracer.in_span(platform_key, attributes: attributes, &block)
end
def resolve_type_lazy(query:, type:, object:, &block)
- platform_key = @platform_resolve_type_key_cache[type]
+ platform_key = @_otel_resolve_type_key_cache[type]
attributes = {}
attributes['graphql.type.name'] = type.graphql_name
attributes['graphql.lazy'] = true
tracer.in_span(platform_key, attributes: attributes, &block)
end
private
- def platform_execute_field_key(field:, &block)
+ def _otel_execute_field_key(field:, &block)
trace_field = trace_field?(field)
- platform_key = @platform_field_key_cache[field] if trace_field
+ platform_key = @_otel_field_key_cache[field] if trace_field
platform_key if platform_key && trace_field
end
def trace_field?(field)
return_type = field.type.unwrap
@@ -153,30 +153,30 @@
else
true
end
end
- def platform_field_key(field)
+ def _otel_field_key(field)
return unless config[:enable_platform_field]
if config[:legacy_platform_span_names]
field.path
else
'graphql.execute_field'
end
end
- def platform_authorized_key(type)
+ def _otel_authorized_key(type)
return unless config[:enable_platform_authorized]
if config[:legacy_platform_span_names]
"#{type.graphql_name}.authorized"
else
'graphql.authorized'
end
end
- def platform_resolve_type_key(type)
+ def _otel_resolve_type_key(type)
return unless config[:enable_platform_resolve_type]
if config[:legacy_platform_span_names]
"#{type.graphql_name}.resolve_type"
else