Class: Contrast::Agent::Assess::Tracker

Inherits:
Object
  • Object
show all
Defined in:
lib/contrast/agent/assess/tracker.rb,
ext/cs__assess_string/cs__assess_string.c,
ext/cs__assess_marshal_module/cs__assess_marshal_module.c

Overview

How we track the Assess properties attached to objects

Finalized objects should run through this class as the Finalizers have tightly coupled dependencies on each other.

Constant Summary collapse

PROPERTIES_HASH =
Contrast::Agent::Assess::Finalizers::Hash.new

Class Method Summary collapse

Class Method Details

.cleanup!Object

Clean PROPERTIES_HASH of any values older than KEEP_AGE ms or have nil properties



61
62
63
# File 'lib/contrast/agent/assess/tracker.rb', line 61

def cleanup!
  PROPERTIES_HASH.cleanup!
end

.copy(source, target) ⇒ Object

Copy the properties from one object to the next, assuming the target does not already have its own properties. This should only ever be called when building PreShift for those objects sources which are already tracked.

Parameters:

  • source (Object)

    the instance from which to copy properties

  • target (Object)

    the instance to which to copy properties



55
56
57
# File 'lib/contrast/agent/assess/tracker.rb', line 55

def copy source, target
  PROPERTIES_HASH[target] ||= properties(source).dup
end

.pre_freeze(source) ⇒ Object



44
45
46
# File 'lib/contrast/agent/assess/tracker.rb', line 44

def pre_freeze source
  PROPERTIES_HASH.pre_freeze(source)
end

.properties(source) ⇒ Contrast::Agent::Assess::Properties?

Retrieve the properties of the given Object, iff they exist.

Parameters:

  • source (Object, nil)

    the thing for which to look up properties.

Returns:



21
22
23
# File 'lib/contrast/agent/assess/tracker.rb', line 21

def properties source
  PROPERTIES_HASH[source]
end

.properties!(source) ⇒ Contrast::Agent::Assess::Properties?

Retrieve the properties of the given Object, returning a new instance if one does not already exist and the source is trackable.

Parameters:

  • source (Object)

    the thing for which to look up properties.

Returns:



30
31
32
33
34
# File 'lib/contrast/agent/assess/tracker.rb', line 30

def properties! source
  return unless trackable?(source)

  PROPERTIES_HASH[source] ||= Contrast::Agent::Assess::Properties.new
end

.trackable?(source) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/contrast/agent/assess/tracker.rb', line 36

def trackable? source
  PROPERTIES_HASH.trackable?(source)
end

.tracked?(source) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/contrast/agent/assess/tracker.rb', line 40

def tracked? source
  PROPERTIES_HASH.tracked?(source)
end