Class: Sqreen::FrameworkCB

Inherits:
CB
  • Object
show all
Defined in:
lib/sqreen/framework_cb.rb

Overview

Framework-aware callback

Direct Known Subclasses

Rules::RuleCB, Rules::RunReqStartActions

Constant Summary

Constants inherited from CB

CB::DEFAULT_PRIORITY

Instance Attribute Summary collapse

Attributes inherited from CB

#klass, #method, #overtimeable

Instance Method Summary collapse

Methods inherited from CB

#failing?, #initialize, #overtime!, #post?, #pre?, #priority, #to_s

Constructor Details

This class inherits a constructor from Sqreen::CB

Instance Attribute Details

#frameworkObject

Returns the value of attribute framework.



12
13
14
# File 'lib/sqreen/framework_cb.rb', line 12

def framework
  @framework
end

Instance Method Details

#record_observation(category, key, observation, at = Time.now.utc) ⇒ Object

Record a metric observation

Parameters:

  • category (String)

    Name of the metric observed

  • key (String)

    aggregation key

  • observation (Object)

    data observed

  • at (Time) (defaults to: Time.now.utc)

    time when observation was made



25
26
27
28
# File 'lib/sqreen/framework_cb.rb', line 25

def record_observation(category, key, observation, at = Time.now.utc)
  return unless framework
  framework.observe(:observations, [category, key, observation, at], [], false)
end

#whitelisted?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/sqreen/framework_cb.rb', line 14

def whitelisted?
  whitelisted = SharedStorage.get(:whitelisted)
  return whitelisted unless whitelisted.nil?
  framework && !framework.whitelisted_match.nil?
end