Class: Datadog::AppSec::Reactive::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/appsec/reactive/operation.rb

Overview

Reactive Engine nested operation tracking

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent = nil, reactive_engine = nil) ⇒ Operation

Returns a new instance of Operation.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/datadog/appsec/reactive/operation.rb', line 14

def initialize(name, parent = nil, reactive_engine = nil)
  Datadog.logger.debug { "operation: #{name} initialize" }
  @name = name
  @parent = parent
  @reactive = select_reactive_engine(reactive_engine, parent)

  # TODO: concurrent store
  # TODO: constant
  Thread.current[:datadog_security_active_operation] = self

  yield self if block_given?
ensure
  finalize
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/datadog/appsec/reactive/operation.rb', line 10

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



10
11
12
# File 'lib/datadog/appsec/reactive/operation.rb', line 10

def parent
  @parent
end

#reactiveObject (readonly)

Returns the value of attribute reactive.



10
11
12
# File 'lib/datadog/appsec/reactive/operation.rb', line 10

def reactive
  @reactive
end

Class Method Details

.activeObject



54
55
56
# File 'lib/datadog/appsec/reactive/operation.rb', line 54

def active
  Thread.current[:datadog_security_active_operation]
end

Instance Method Details

#finalizeObject



38
39
40
41
# File 'lib/datadog/appsec/reactive/operation.rb', line 38

def finalize
  Datadog.logger.debug { "operation: #{name} finalize" }
  Thread.current[:datadog_security_active_operation] = parent
end

#publish(address, data) ⇒ Object



34
35
36
# File 'lib/datadog/appsec/reactive/operation.rb', line 34

def publish(address, data)
  reactive.publish(address, data)
end

#subscribe(*addresses, &block) ⇒ Object

TODO: use structs instead of an arg splat



30
31
32
# File 'lib/datadog/appsec/reactive/operation.rb', line 30

def subscribe(*addresses, &block)
  reactive.subscribe(*addresses, &block)
end