Class: OpenTelemetry::Instrumentation::GraphQL::Tracers::GraphQLTracer
- Inherits:
-
GraphQL::Tracing::PlatformTracing
- Object
- GraphQL::Tracing::PlatformTracing
- OpenTelemetry::Instrumentation::GraphQL::Tracers::GraphQLTracer
- Defined in:
- lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb
Overview
GraphQLTracer contains the OpenTelemetry tracer implementation compatible with the GraphQL tracer API
Instance Method Summary collapse
- #platform_authorized_key(type) ⇒ Object
- #platform_field_key(type, field) ⇒ Object
- #platform_resolve_type_key(type) ⇒ Object
- #platform_trace(platform_key, key, data) ⇒ Object
Instance Method Details
#platform_authorized_key(type) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb', line 58 def (type) return unless config[:enable_platform_authorized] if config[:legacy_platform_span_names] "#{type.graphql_name}.authorized" else 'graphql.authorized' end end |
#platform_field_key(type, field) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb', line 48 def platform_field_key(type, field) return unless config[:enable_platform_field] if config[:legacy_platform_span_names] "#{type.graphql_name}.#{field.graphql_name}" else 'graphql.execute_field' end end |
#platform_resolve_type_key(type) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb', line 68 def platform_resolve_type_key(type) return unless config[:enable_platform_resolve_type] if config[:legacy_platform_span_names] "#{type.graphql_name}.resolve_type" else 'graphql.resolve_type' end end |
#platform_trace(platform_key, key, data) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb', line 27 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.tap do |response| next unless key == 'validate' errors = response[:errors]&.compact&.map(&:to_h) || [] unless errors.empty? span.add_event( 'graphql.validation.error', attributes: { 'exception.message' => errors.to_json } ) end end end end |