Sha256: f88ee3d851fbde777270b35b5b6e8d7df39e7b6b75f918467df9b03a8b073af7

Contents?: true

Size: 997 Bytes

Versions: 4

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

if Gem.loaded_specs['graphql'] && Gem.loaded_specs['graphql'].version >= Gem::Version.new('2.0.19')
  require_relative 'unified_trace'
end

module Datadog
  module Tracing
    module Contrib
      module GraphQL
        # Provides instrumentation for `graphql` through the GraphQL's tracing with methods defined in UnifiedTrace
        module UnifiedTracePatcher
          module_function

          # TODO: `GraphQL::Schema.trace_with` and `YOUR_SCHEMA.trace_with` don't mix.
          # TODO: They create duplicate spans when combined.
          # TODO: We should measure how frequently users use `YOUR_SCHEMA.trace_with`, and hopefully we can remove it.
          def patch!(schemas)
            if schemas.empty?
              ::GraphQL::Schema.trace_with(UnifiedTrace)
            else
              schemas.each do |schema|
                schema.trace_with(UnifiedTrace)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
datadog-2.7.0 lib/datadog/tracing/contrib/graphql/unified_trace_patcher.rb
datadog-2.6.0 lib/datadog/tracing/contrib/graphql/unified_trace_patcher.rb
datadog-2.5.0 lib/datadog/tracing/contrib/graphql/unified_trace_patcher.rb
datadog-2.4.0 lib/datadog/tracing/contrib/graphql/unified_trace_patcher.rb