Skip to content

Commit

Permalink
Remove method call on SpanOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Jan 16, 2024
1 parent be70e18 commit 927e61e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
12 changes: 4 additions & 8 deletions lib/graphql/tracing/data_dog_trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def initialize(tracer: nil, analytics_enabled: false, analytics_sample_rate: 1.0
}.each do |trace_method, trace_key|
module_eval <<-RUBY, __FILE__, __LINE__
def #{trace_method}(**data)
@tracer.trace("#{trace_key}", service: @service_name) do |span|
span.span_type = 'custom'
@tracer.trace("#{trace_key}", service: @service_name, type: 'custom') do |span|
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, '#{trace_method}')
Expand Down Expand Up @@ -89,8 +88,7 @@ def execute_field_span(span_key, query, field, ast_node, arguments, object)
nil
end
if platform_key && trace_field
@tracer.trace(platform_key, service: @service_name) do |span|
span.span_type = 'custom'
@tracer.trace(platform_key, service: @service_name, type: 'custom') do |span|
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, span_key)
Expand Down Expand Up @@ -125,8 +123,7 @@ def authorized(query:, type:, object:)
def authorized_span(span_key, object, type, query)
platform_key = @platform_key_cache[DataDogTrace].platform_authorized_key_cache[type]
@tracer.trace(platform_key, service: @service_name) do |span|
span.span_type = 'custom'
@tracer.trace(platform_key, service: @service_name, type: 'custom') do |span|
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, span_key)
Expand Down Expand Up @@ -158,8 +155,7 @@ def resolve_type_lazy(object:, type:, query:)
def resolve_type_span(span_key, object, type, query)
platform_key = @platform_key_cache[DataDogTrace].platform_resolve_type_key_cache[type]
@tracer.trace(platform_key, service: @service_name) do |span|
span.span_type = 'custom'
@tracer.trace(platform_key, service: @service_name, type: 'custom') do |span|
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, span_key)
Expand Down
3 changes: 1 addition & 2 deletions lib/graphql/tracing/data_dog_tracing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class DataDogTracing < PlatformTracing
}

def platform_trace(platform_key, key, data)
tracer.trace(platform_key, service: service_name) do |span|
span.span_type = 'custom'
tracer.trace(platform_key, service: service_name, type: 'custom') do |span|
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)
Expand Down
1 change: 0 additions & 1 deletion spec/support/datadog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def resource=(resource_name)
SPAN_RESOURCE_NAMES << resource_name
end

def span_type=(*args)end
def set_tag(key, value)
SPAN_TAGS << [key, value]
end
Expand Down

0 comments on commit 927e61e

Please sign in to comment.