Sha256: f8b392f132ffad0e5dce1e8ce8985c07eb4efecb7863fbccaa4c9f339811c4bb
Contents?: true
Size: 1.74 KB
Versions: 4
Compression:
Stored size: 1.74 KB
Contents
require 'ddtrace/ext/app_types' require 'ddtrace/ext/http' module Datadog module Contrib module GraphQL # Provides instrumentation for `graphql` through the GraphQL tracing framework module Patcher include Base register_as :graphql option :tracer, default: Datadog.tracer option :service_name, default: 'ruby-graphql', depends_on: [:tracer] do |value| get_option(:tracer).set_service_info(value, 'ruby-graphql', Ext::AppTypes::WEB) value end option :schemas class << self def patch return patched? if patched? || !compatible? || get_option(:schemas).nil? get_option(:schemas).each { |s| patch_schema!(s) } @patched = true end def patch_schema!(schema) tracer = get_option(:tracer) service_name = get_option(:service_name) if schema.respond_to?(:use) schema.use( ::GraphQL::Tracing::DataDogTracing, tracer: tracer, service: service_name ) else schema.define do use( ::GraphQL::Tracing::DataDogTracing, tracer: tracer, service: service_name ) end end end def patched? return @patched if defined?(@patched) @patched = false end private def compatible? defined?(::GraphQL) \ && defined?(::GraphQL::Tracing::DataDogTracing) \ && Gem.loaded_specs['graphql'].version >= Gem::Version.new('1.7.9') end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems