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.
9 10 11 12 13 |
# File 'lib/datadog/appsec/scope.rb', line 9 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.
7 8 9 |
# File 'lib/datadog/appsec/scope.rb', line 7 def processor_context @processor_context end |
#service_entry_span ⇒ Object (readonly)
Returns the value of attribute service_entry_span.
7 8 9 |
# File 'lib/datadog/appsec/scope.rb', line 7 def service_entry_span @service_entry_span end |
#trace ⇒ Object (readonly)
Returns the value of attribute trace.
7 8 9 |
# File 'lib/datadog/appsec/scope.rb', line 7 def trace @trace end |
Class Method Details
.activate_scope(trace, service_entry_span, processor) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/datadog/appsec/scope.rb', line 20 def activate_scope(trace, service_entry_span, processor) raise ActiveScopeError, 'another scope is active, nested scopes are not supported' if active_scope context = processor.new_context self.active_scope = new(trace, service_entry_span, context) end |
.active_scope ⇒ Object
37 38 39 |
# File 'lib/datadog/appsec/scope.rb', line 37 def active_scope Thread.current[:datadog_appsec_active_scope] end |
.deactivate_scope ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/datadog/appsec/scope.rb', line 27 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
15 16 17 |
# File 'lib/datadog/appsec/scope.rb', line 15 def finalize @processor_context.finalize end |