Class: NewRelic::Binding::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/newrelic_platform_binding/context.rb

Constant Summary collapse

AGGREGATION_LIMIT =
20

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(license_key) ⇒ Context

Returns a new instance of Context.



8
9
10
11
12
13
14
15
16
# File 'lib/newrelic_platform_binding/context.rb', line 8

def initialize(license_key)
  @version = nil
  @host = nil
  @request = Request.new(self)
  @pid = nil
  @license_key = license_key
  @components = []
  @aggregation_start = Time.now
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



5
6
7
# File 'lib/newrelic_platform_binding/context.rb', line 5

def components
  @components
end

#hostObject

Returns the value of attribute host.



6
7
8
# File 'lib/newrelic_platform_binding/context.rb', line 6

def host
  @host
end

#license_keyObject (readonly)

Returns the value of attribute license_key.



5
6
7
# File 'lib/newrelic_platform_binding/context.rb', line 5

def license_key
  @license_key
end

#pidObject

Returns the value of attribute pid.



6
7
8
# File 'lib/newrelic_platform_binding/context.rb', line 6

def pid
  @pid
end

#versionObject

Returns the value of attribute version.



6
7
8
# File 'lib/newrelic_platform_binding/context.rb', line 6

def version
  @version
end

Instance Method Details

#create_component(name, guid) ⇒ Object



18
19
20
21
22
# File 'lib/newrelic_platform_binding/context.rb', line 18

def create_component(name, guid)
  component = Component.new(name, guid)
  @components.push(component)
  return component
end

#find_component(name, guid) ⇒ Object



30
31
32
# File 'lib/newrelic_platform_binding/context.rb', line 30

def find_component(name, guid)
  @components.find { |c| c.key == name + guid }
end

#get_component(name, guid) ⇒ Object



24
25
26
27
28
# File 'lib/newrelic_platform_binding/context.rb', line 24

def get_component(name, guid)
  component = find_component(name, guid)
  component = create_component(name, guid) if component.nil?
  component
end

#get_requestObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/newrelic_platform_binding/context.rb', line 34

def get_request()
  if past_aggregation_limit?
    @components.each do |component|
      component.last_delivered_at = nil
    end
    @request = Request.new(self)
  elsif @request.delivered?
    @request = Request.new(self)
  else
    @request
  end
end

#last_request_delivered_at=(delivered_at) ⇒ Object



47
48
49
# File 'lib/newrelic_platform_binding/context.rb', line 47

def last_request_delivered_at=(delivered_at)
  @aggregation_start = delivered_at
end