Class: Datadog::AppSec::Scope
- Inherits:
-
Object
- Object
- Datadog::AppSec::Scope
- Defined in:
- lib/datadog/appsec/scope.rb
Overview
Capture context essential to consistently call processor and report via traces
Defined Under Namespace
Classes: ActiveScopeError, InactiveScopeError
Instance Attribute Summary collapse
-
#processor_context ⇒ Object
readonly
Returns the value of attribute processor_context.
-
#service_entry_span ⇒ Object
readonly
Returns the value of attribute service_entry_span.
-
#trace ⇒ Object
readonly
Returns the value of attribute trace.
Class Method Summary collapse
- .activate_scope(trace, service_entry_span, processor) ⇒ Object
- .active_scope ⇒ Object
- .deactivate_scope ⇒ Object
Instance Method Summary collapse
- #finalize ⇒ Object
-
#initialize(trace, service_entry_span, processor_context) ⇒ Scope
constructor
A new instance of Scope.
Constructor Details
#initialize(trace, service_entry_span, processor_context) ⇒ Scope
Returns a new instance of Scope.
11 12 13 14 15 |
# File 'lib/datadog/appsec/scope.rb', line 11 def initialize(trace, service_entry_span, processor_context) @trace = trace @service_entry_span = service_entry_span @processor_context = processor_context end |
Instance Attribute Details
#processor_context ⇒ Object (readonly)
Returns the value of attribute processor_context.
9 10 11 |
# File 'lib/datadog/appsec/scope.rb', line 9 def processor_context @processor_context end |
#service_entry_span ⇒ Object (readonly)
Returns the value of attribute service_entry_span.
9 10 11 |
# File 'lib/datadog/appsec/scope.rb', line 9 def service_entry_span @service_entry_span end |
#trace ⇒ Object (readonly)
Returns the value of attribute trace.
9 10 11 |
# File 'lib/datadog/appsec/scope.rb', line 9 def trace @trace end |
Class Method Details
.activate_scope(trace, service_entry_span, processor) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/datadog/appsec/scope.rb', line 22 def activate_scope(trace, service_entry_span, processor) raise ActiveScopeError, 'another scope is active, nested scopes are not supported' if active_scope context = Datadog::AppSec::Processor::Context.new(processor) self.active_scope = new(trace, service_entry_span, context) end |
.active_scope ⇒ Object
40 41 42 |
# File 'lib/datadog/appsec/scope.rb', line 40 def active_scope Thread.current[:datadog_appsec_active_scope] end |
.deactivate_scope ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/datadog/appsec/scope.rb', line 30 def deactivate_scope raise InactiveScopeError, 'no scope is active, nested scopes are not supported' unless active_scope scope = active_scope reset_active_scope scope.finalize end |
Instance Method Details
#finalize ⇒ Object
17 18 19 |
# File 'lib/datadog/appsec/scope.rb', line 17 def finalize @processor_context.finalize end |