From 2e16b4a41f96e03b46508d399c8893f9c3eb3787 Mon Sep 17 00:00:00 2001 From: Yannick Utard Date: Thu, 10 Jul 2025 19:35:23 +0200 Subject: [PATCH 1/2] Support GraphQL::Query::Partial in graphql instrumentation Signed-off-by: Yannick Utard --- .../instrumentation/graphql/tracers/graphql_trace.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb index cb82bf2c7f..1870f2b8bd 100644 --- a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb +++ b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb @@ -99,8 +99,12 @@ def analyze_query(query:, &block) def execute_query(query:, &block) attributes = {} attributes['graphql.operation.name'] = query.selected_operation_name if query.selected_operation_name - attributes['graphql.operation.type'] = query.selected_operation.operation_type - attributes['graphql.document'] = query.query_string + if query.is_a?(::GraphQL::Query::Partial) + attributes['graphql.partial.path'] = query.path.to_s + else + attributes['graphql.operation.type'] = query.selected_operation.operation_type + attributes['graphql.document'] = query.query_string + end tracer.in_span('graphql.execute_query', attributes: attributes) do super From d78a0285a2e3d101ddf07d3378922f68bad284a1 Mon Sep 17 00:00:00 2001 From: Yannick Utard Date: Wed, 16 Jul 2025 13:28:01 +0200 Subject: [PATCH 2/2] Check if GraphQL::Query::Partial is defined Signed-off-by: Yannick Utard --- .../instrumentation/graphql/tracers/graphql_trace.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb index 1870f2b8bd..c91f374a53 100644 --- a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb +++ b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb @@ -99,7 +99,7 @@ def analyze_query(query:, &block) def execute_query(query:, &block) attributes = {} attributes['graphql.operation.name'] = query.selected_operation_name if query.selected_operation_name - if query.is_a?(::GraphQL::Query::Partial) + if defined?(::GraphQL::Query::Partial) && query.is_a?(::GraphQL::Query::Partial) attributes['graphql.partial.path'] = query.path.to_s else attributes['graphql.operation.type'] = query.selected_operation.operation_type