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: DownstreamResponseStore, Store
Instance Attribute Summary collapse
-
#downstream_responses ⇒ Object
readonly
Returns the value of attribute downstream_responses.
-
#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_ignored_downstream_response_body(reason) ⇒ Object
- #record_rasp(result, type:, phase: nil) ⇒ Object
- #record_waf(result) ⇒ Object
Constructor Details
#initialize ⇒ Collector
Returns a new instance of Collector.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 30 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, downstream_requests: 0 ) @rasp = Store.new( evals: 0, matches: 0, errors: 0, timeouts: 0, duration_ns: 0, duration_ext_ns: 0, inputs_truncated: 0, downstream_requests: 0 ) @downstream_responses = DownstreamResponseStore.new( content_type_invalid: 0, content_length_missing: 0, content_length_too_big: 0, content_exceed_content_length: 0 ) end |
Instance Attribute Details
#downstream_responses ⇒ Object (readonly)
Returns the value of attribute downstream_responses.
28 29 30 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 28 def downstream_responses @downstream_responses end |
#rasp ⇒ Object (readonly)
Returns the value of attribute rasp.
28 29 30 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 28 def rasp @rasp end |
#waf ⇒ Object (readonly)
Returns the value of attribute waf.
28 29 30 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 28 def waf @waf end |
Instance Method Details
#record_ignored_downstream_response_body(reason) ⇒ Object
74 75 76 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 74 def record_ignored_downstream_response_body(reason) @mutex.synchronize { @downstream_responses[reason] += 1 } end |
#record_rasp(result, type:, phase: nil) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 61 def record_rasp(result, type:, phase: nil) @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? @rasp.downstream_requests += 1 if type == Ext::RASP_SSRF && phase == Ext::RASP_REQUEST_PHASE end end |
#record_waf(result) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/datadog/appsec/metrics/collector.rb', line 49 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 |