lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb in opentelemetry-instrumentation-graphql-0.18.1 vs lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb in opentelemetry-instrumentation-graphql-0.19.0

- old
+ new

@@ -25,11 +25,21 @@ } def platform_trace(platform_key, key, data) return yield if platform_key.nil? - tracer.in_span(platform_key, attributes: attributes_for(key, data)) do |_span| - yield + tracer.in_span(platform_key, attributes: attributes_for(key, data)) do |span| + yield.tap do |response| + errors = response[:errors]&.compact&.map { |e| e.to_h }&.to_json if key == 'validate' + unless errors.nil? + span.add_event( + 'graphql.validation.error', + attributes: { + 'message' => errors + } + ) + end + end end end def platform_field_key(type, field) return unless config[:enable_platform_field]