Module: Datadog::Contrib::GraphQL::Patcher
- Includes:
- Patcher
- Defined in:
- lib/ddtrace/contrib/graphql/patcher.rb
Overview
Provides instrumentation for graphql
through the GraphQL tracing framework
Class Method Summary collapse
- .get_option(option) ⇒ Object
- .patch ⇒ Object
- .patch_schema!(schema) ⇒ Object
- .target_version ⇒ Object
Methods included from Patcher
Class Method Details
.get_option(option) ⇒ Object
55 56 57 |
# File 'lib/ddtrace/contrib/graphql/patcher.rb', line 55 def get_option(option) Datadog.configuration[:graphql].get_option(option) end |
.patch ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/ddtrace/contrib/graphql/patcher.rb', line 17 def patch return if get_option(:schemas).nil? require 'ddtrace/ext/app_types' require 'ddtrace/ext/http' get_option(:schemas).each { |s| patch_schema!(s) } end |
.patch_schema!(schema) ⇒ Object
25 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 |
# File 'lib/ddtrace/contrib/graphql/patcher.rb', line 25 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 indirectly delegates the tracer instance # to +Datadog.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 indirectly delegates the tracer instance # to +Datadog.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
13 14 15 |
# File 'lib/ddtrace/contrib/graphql/patcher.rb', line 13 def target_version Integration.version end |