Class: Datadog::AppSec::Metrics::Collector
- Inherits:
-
Object
- Object
- Datadog::AppSec::Metrics::Collector
- Defined in:
- lib/datadog/appsec/metrics/collector.rb
Overview
A class responsible for collecting WAF and RASP call metrics.
Defined Under Namespace
Classes: Store
Instance Attribute Summary collapse
-
#rasp ⇒ Object
readonly
Returns the value of attribute rasp.
-
#waf ⇒ Object
readonly
Returns the value of attribute waf.
Instance Method Summary collapse
-
#initialize ⇒ Collector
constructor
A new instance of Collector.
- #record_rasp(result) ⇒ Object
- #record_waf(result) ⇒ Object
Constructor Details
#initialize ⇒ Collector
Returns a new instance of Collector.
12 13 14 15 16 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 12 def initialize @mutex = Mutex.new @waf = Store.new(evals: 0, timeouts: 0, duration_ns: 0, duration_ext_ns: 0) @rasp = Store.new(evals: 0, timeouts: 0, duration_ns: 0, duration_ext_ns: 0) end |
Instance Attribute Details
#rasp ⇒ Object (readonly)
Returns the value of attribute rasp.
10 11 12 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 10 def rasp @rasp end |
#waf ⇒ Object (readonly)
Returns the value of attribute waf.
10 11 12 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 10 def waf @waf end |
Instance Method Details
#record_rasp(result) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 27 def record_rasp(result) @mutex.synchronize do @rasp.evals += 1 @rasp.timeouts += 1 if result.timeout? @rasp.duration_ns += result.duration_ns @rasp.duration_ext_ns += result.duration_ext_ns end end |
#record_waf(result) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 18 def record_waf(result) @mutex.synchronize do @waf.evals += 1 @waf.timeouts += 1 if result.timeout? @waf.duration_ns += result.duration_ns @waf.duration_ext_ns += result.duration_ext_ns end end |