Module: Datadog::AppSec::Contrib::GraphQL::Gateway::Watcher
- Defined in:
- lib/datadog/appsec/contrib/graphql/gateway/watcher.rb
Overview
Watcher for Rack gateway events
Class Method Summary collapse
- .watch ⇒ Object
-
.watch_multiplex(gateway = Instrumentation.gateway) ⇒ Object
This time we don’t throw but use next.
Class Method Details
.watch ⇒ Object
16 17 18 19 20 |
# File 'lib/datadog/appsec/contrib/graphql/gateway/watcher.rb', line 16 def watch gateway = Instrumentation.gateway watch_multiplex(gateway) end |
.watch_multiplex(gateway = Instrumentation.gateway) ⇒ Object
This time we don’t throw but use next
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 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/datadog/appsec/contrib/graphql/gateway/watcher.rb', line 23 def watch_multiplex(gateway = Instrumentation.gateway) gateway.watch('graphql.multiplex', :appsec) do |stack, gateway_multiplex| block = false event = nil scope = AppSec::Scope.active_scope if scope AppSec::Reactive::Operation.new('graphql.multiplex') do |op| GraphQL::Reactive::Multiplex.subscribe(op, scope.processor_context) do |result| event = { waf_result: result, trace: scope.trace, span: scope.service_entry_span, multiplex: gateway_multiplex, actions: result.actions } Datadog::AppSec::Event.tag_and_keep!(scope, result) scope.processor_context.events << event end block = GraphQL::Reactive::Multiplex.publish(op, gateway_multiplex) end end next [nil, [[:block, event]]] if block ret, res = stack.call(gateway_multiplex.arguments) if event res ||= [] res << [:monitor, event] end [ret, res] end end |