From 0d51457d45a880cae4a6cd76ecf349411fef8567 Mon Sep 17 00:00:00 2001 From: Toney Mathews Date: Tue, 19 Jul 2022 08:46:13 -0400 Subject: [PATCH] Add example and testing for graphql 1.13 --- instrumentation/graphql/Appraisals | 4 ++++ instrumentation/graphql/README.md | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/instrumentation/graphql/Appraisals b/instrumentation/graphql/Appraisals index 24efd5c12..b74a9806c 100644 --- a/instrumentation/graphql/Appraisals +++ b/instrumentation/graphql/Appraisals @@ -4,6 +4,10 @@ # # SPDX-License-Identifier: Apache-2.0 +appraise 'graphql-1.13' do + gem 'graphql', '~> 1.13.0' +end + appraise 'graphql-1.11' do gem 'graphql', '~> 1.11.0' end diff --git a/instrumentation/graphql/README.md b/instrumentation/graphql/README.md index c10448ae3..f9637aa61 100644 --- a/instrumentation/graphql/README.md +++ b/instrumentation/graphql/README.md @@ -53,6 +53,27 @@ OpenTelemetry::SDK.configure do |c| end ``` +#### GraphQL context configuration + +Optionally, GraphQL execution context can include tracing option keys to control tracing behaviour independently per execution. + +An option's global configuration must be enabled for the associated context option to be respected. This is supported for `graphql-ruby` version `>= 1.13.13 < 2` or `>= 2.0.9`. + +| | Global Enabled | Global Disabled | +|:---:|:---:|:---:| +| **Context Unset** | ✅ | ❌ | +| **Context Enabled** | ✅ | ❌ | +| **Context Disabled** | ❌ | ❌ | + +```ruby +query = GraphQL::Query.new(MyAppSchema, 'query { foo }') + +opentelemetry_context = query.context.namespace(:opentelemetry) +opentelemetry_context[:enable_platform_field] = true +opentelemetry_context[:enable_platform_authorized] = true +opentelemetry_context[:enable_platform_resolve_type] = true +``` + ## Examples An example of usage can be seen in [`example/graphql.rb`](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/graphql/example/graphql.rb).