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.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 21 def initialize @mutex = Mutex.new @waf = Store.new( evals: 0, matches: 0, errors: 0, timeouts: 0, duration_ns: 0, duration_ext_ns: 0, inputs_truncated: 0 ) @rasp = Store.new( evals: 0, matches: 0, errors: 0, timeouts: 0, duration_ns: 0, duration_ext_ns: 0, inputs_truncated: 0 ) end |
Instance Attribute Details
#rasp ⇒ Object (readonly)
Returns the value of attribute rasp.
19 20 21 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 19 def rasp @rasp end |
#waf ⇒ Object (readonly)
Returns the value of attribute waf.
19 20 21 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 19 def waf @waf end |
Instance Method Details
#record_rasp(result) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 44 def record_rasp(result) @mutex.synchronize do @rasp.evals += 1 @waf.matches += 1 if result.match? @waf.errors += 1 if result.error? @rasp.timeouts += 1 if result.timeout? @rasp.duration_ns += result.duration_ns @rasp.duration_ext_ns += result.duration_ext_ns @rasp.inputs_truncated += 1 if result.input_truncated? end end |
#record_waf(result) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 32 def record_waf(result) @mutex.synchronize do @waf.evals += 1 @waf.matches += 1 if result.match? @waf.errors += 1 if result.error? @waf.timeouts += 1 if result.timeout? @waf.duration_ns += result.duration_ns @waf.duration_ext_ns += result.duration_ext_ns @waf.inputs_truncated += 1 if result.input_truncated? end end |