Sha256: 55f1f7e919d0442e184f3e1c78d2511862a441bc27505a5c41caa7d929ab85fc

Contents?: true

Size: 1.91 KB

Versions: 12

Compression:

Stored size: 1.91 KB

Contents

# frozen_string_literal: true

require_relative '../analytics'
require_relative '../patcher'
require_relative 'tracing_patcher'
require_relative 'trace_patcher'
require_relative 'unified_trace_patcher'

module Datadog
  module Tracing
    module Contrib
      module GraphQL
        # Provides instrumentation for `graphql` through the GraphQL tracing framework
        module Patcher
          include Contrib::Patcher

          module_function

          def target_version
            Integration.version
          end

          def patch
            # DEV-3.0: We should remove as many patching options as possible, given the alternatives do not
            # DEV-3.0: provide any benefit to the recommended `with_unified_tracer` patching method.
            # DEV-3.0: `with_deprecated_tracer` is likely safe to remove.
            # DEV-3.0: `with_unified_tracer: false` should be removed if possible.
            # DEV-3.0: `with_unified_tracer: true` should be the default and hopefully not even necessary as an option.
            if configuration[:with_deprecated_tracer]
              TracingPatcher.patch!(schemas)
            elsif Integration.trace_supported?
              if configuration[:with_unified_tracer]
                UnifiedTracePatcher.patch!(schemas)
              else
                TracePatcher.patch!(schemas)
              end
            else
              Datadog.logger.warn(
                "GraphQL version (#{target_version}) does not support GraphQL::Tracing::DataDogTrace"\
                'or Datadog::Tracing::Contrib::GraphQL::UnifiedTrace.'\
                'Falling back to GraphQL::Tracing::DataDogTracing.'
              )
              TracingPatcher.patch!(schemas)
            end
          end

          def configuration
            Datadog.configuration.tracing[:graphql]
          end

          def schemas
            configuration[:schemas]
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
datadog-2.12.2 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.12.1 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.12.0 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.11.0 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.10.0 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.9.0 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.8.0 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.7.1 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.7.0 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.6.0 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.5.0 lib/datadog/tracing/contrib/graphql/patcher.rb
datadog-2.4.0 lib/datadog/tracing/contrib/graphql/patcher.rb