Module: Datadog::Tracing::Contrib::GraphQL::Patcher
- Includes:
- Patcher
- Defined in:
- lib/datadog/tracing/contrib/graphql/patcher.rb
Overview
Provides instrumentation for ‘graphql` through the GraphQL tracing framework
Defined Under Namespace
Modules: PatchLegacyGem
Class Method Summary collapse
- .get_option(option) ⇒ Object
- .patch ⇒ Object
-
.patch_legacy_gem! ⇒ Object
Before github.com/rmosolgo/graphql-ruby/pull/4038 was introduced, we were left with incompatibilities between ddtrace 1.0 and older graphql gem versions.
- .patch_schema!(schema) ⇒ Object
- .target_version ⇒ Object
Methods included from Patcher
Class Method Details
.get_option(option) ⇒ Object
64 65 66 |
# File 'lib/datadog/tracing/contrib/graphql/patcher.rb', line 64 def get_option(option) Datadog.configuration.tracing[:graphql].get_option(option) end |
.patch ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/datadog/tracing/contrib/graphql/patcher.rb', line 18 def patch if (schemas = get_option(:schemas)) schemas.each { |s| patch_schema!(s) } end patch_legacy_gem! end |
.patch_legacy_gem! ⇒ Object
Before github.com/rmosolgo/graphql-ruby/pull/4038 was introduced, we were left with incompatibilities between ddtrace 1.0 and older graphql gem versions.
58 59 60 61 62 |
# File 'lib/datadog/tracing/contrib/graphql/patcher.rb', line 58 def patch_legacy_gem! return unless Gem::Version.new(::GraphQL::VERSION) <= Gem::Version.new('2.0.6') ::GraphQL::Tracing::DataDogTracing.prepend(PatchLegacyGem) end |
.patch_schema!(schema) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/datadog/tracing/contrib/graphql/patcher.rb', line 26 def patch_schema!(schema) service_name = get_option(:service_name) analytics_enabled = Contrib::Analytics.enabled?(get_option(:analytics_enabled)) analytics_sample_rate = get_option(:analytics_sample_rate) if schema.respond_to?(:use) schema.use( ::GraphQL::Tracing::DataDogTracing, # By default, Tracing::DataDogTracing holds a reference to a tracer. # If we provide a tracer argument here it will be eagerly cached, # and Tracing::DataDogTracing will send traces to a stale tracer instance. service: service_name, analytics_enabled: analytics_enabled, analytics_sample_rate: analytics_sample_rate ) else schema.define do use( ::GraphQL::Tracing::DataDogTracing, # By default, Tracing::DataDogTracing holds a reference to a tracer. # If we provide a tracer argument here it will be eagerly cached, # and Tracing::DataDogTracing will send traces to a stale tracer instance. service: service_name, analytics_enabled: analytics_enabled, analytics_sample_rate: analytics_sample_rate ) end end end |
.target_version ⇒ Object
14 15 16 |
# File 'lib/datadog/tracing/contrib/graphql/patcher.rb', line 14 def target_version Integration.version end |