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
Methods included from Patcher
Class Method Details
.get_option(option) ⇒ Object
57 58 59 |
# File 'lib/ddtrace/contrib/graphql/patcher.rb', line 57 def get_option(option) Datadog.configuration[:graphql].get_option(option) end |
.patch ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ddtrace/contrib/graphql/patcher.rb', line 16 def patch return if get_option(:schemas).nil? do_once(:graphql) do begin require 'ddtrace/ext/app_types' require 'ddtrace/ext/http' get_option(:schemas).each { |s| patch_schema!(s) } rescue StandardError => e Datadog::Tracer.log.error("Unable to apply GraphQL integration: #{e}") end end end |
.patch_schema!(schema) ⇒ Object
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 55 |
# File 'lib/ddtrace/contrib/graphql/patcher.rb', line 30 def patch_schema!(schema) tracer = get_option(:tracer) 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, tracer: tracer, service: service_name, analytics_enabled: analytics_enabled, analytics_sample_rate: analytics_sample_rate ) else schema.define do use( ::GraphQL::Tracing::DataDogTracing, tracer: tracer, service: service_name, analytics_enabled: analytics_enabled, analytics_sample_rate: analytics_sample_rate ) end end end |
.patched? ⇒ Boolean
12 13 14 |
# File 'lib/ddtrace/contrib/graphql/patcher.rb', line 12 def patched? done?(:graphql) end |