Class: GraphQL::Tracing::SentryTrace::SentryMonitor
- Inherits:
-
MonitorTrace::Monitor
- Object
- MonitorTrace::Monitor
- GraphQL::Tracing::SentryTrace::SentryMonitor
- Defined in:
- lib/graphql/tracing/sentry_trace.rb
Defined Under Namespace
Classes: Event
Constant Summary
Constants included from MonitorTrace::Monitor::GraphQLPrefixNames
MonitorTrace::Monitor::GraphQLPrefixNames::ANALYZE_NAME, MonitorTrace::Monitor::GraphQLPrefixNames::EXECUTE_NAME, MonitorTrace::Monitor::GraphQLPrefixNames::LEX_NAME, MonitorTrace::Monitor::GraphQLPrefixNames::PARSE_NAME, MonitorTrace::Monitor::GraphQLPrefixNames::VALIDATE_NAME
Instance Method Summary collapse
Methods included from MonitorTrace::Monitor::GraphQLPrefixNames
#platform_authorized_key, #platform_field_key, #platform_resolve_type_key, #platform_source_class_key
Methods inherited from MonitorTrace::Monitor
#fallback_transaction_name, #initialize, #name_for, #start_event, #transaction_name
Constructor Details
This class inherits a constructor from GraphQL::Tracing::MonitorTrace::Monitor
Instance Method Details
#instrument(keyword, object) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/graphql/tracing/sentry_trace.rb', line 17 def instrument(keyword, object) return yield unless Sentry.initialized? platform_key = name_for(keyword, object) Sentry.with_child_span(op: platform_key, start_timestamp: Sentry.utc_now.to_f) do |span| result = yield return result unless span span.finish if keyword == :execute queries = object.queries operation_names = queries.map{|q| operation_name(q) } span.set_description(operation_names.join(", ")) if queries.size == 1 query = queries.first set_this_txn_name = query.context[:set_sentry_transaction_name] if set_this_txn_name == true || (set_this_txn_name.nil? && @set_transaction_name) Sentry.configure_scope do |scope| scope.set_transaction_name(transaction_name(query)) end end span.set_data('graphql.document', query.query_string) if query.selected_operation_name span.set_data('graphql.operation.name', query.selected_operation_name) end span.set_data('graphql.operation.type', query.selected_operation.operation_type) end end result end end |