lib/graphql/tracing/platform_tracing.rb in graphql-2.0.17.2 vs lib/graphql/tracing/platform_tracing.rb in graphql-2.0.18
- old
+ new
@@ -38,11 +38,11 @@
true
end
platform_key = if trace_field
context = data.fetch(:query).context
- cached_platform_key(context, field, :field) { platform_field_key(data[:owner], field) }
+ cached_platform_key(context, field, :field) { platform_field_key(field.owner, field) }
else
nil
end
if platform_key && trace_field
@@ -71,11 +71,23 @@
yield
end
end
def self.use(schema_defn, options = {})
- tracer = self.new(**options)
- schema_defn.tracer(tracer)
+ if options[:legacy_tracing]
+ tracer = self.new(**options)
+ schema_defn.tracer(tracer)
+ else
+ tracing_name = self.name.split("::").last
+ trace_name = tracing_name.sub("Tracing", "Trace")
+ if GraphQL::Tracing.const_defined?(trace_name, false)
+ trace_module = GraphQL::Tracing.const_get(trace_name)
+ schema_defn.trace_with(trace_module, **options)
+ else
+ tracer = self.new(**options)
+ schema_defn.tracer(tracer)
+ end
+ end
end
private
# Get the transaction name based on the operation type and name if possible, or fall back to a user provided