Class: NewRelic::Agent::Sampler

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/sampler.rb

Defined Under Namespace

Classes: Unsupported

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil) ⇒ Sampler

The ID passed in here is unused by our code, but is preserved in case we have clients who are defining their own subclasses of this class, and expecting to be able to call super with an ID.

[View source]

55
56
57
# File 'lib/new_relic/agent/sampler.rb', line 55

def initialize(id = nil)
  @id = id || self.class.shorthand_name
end

Class Attribute Details

.shorthand_nameObject (readonly)


23
24
25
# File 'lib/new_relic/agent/sampler.rb', line 23

def shorthand_name
  @shorthand_name
end

Instance Attribute Details

#idObject (readonly)


19
20
21
# File 'lib/new_relic/agent/sampler.rb', line 19

def id
  @id
end

Class Method Details

.enabled?Boolean

Returns:

  • (Boolean)
[View source]

39
40
41
42
43
44
45
46
# File 'lib/new_relic/agent/sampler.rb', line 39

def self.enabled?
  if shorthand_name
    config_key = "disable_#{shorthand_name}_sampler"
    !(Agent.config[config_key])
  else
    true
  end
end

.inherited(subclass) ⇒ Object

[View source]

30
31
32
# File 'lib/new_relic/agent/sampler.rb', line 30

def self.inherited(subclass)
  @sampler_classes << subclass
end

.named(new_name) ⇒ Object

[View source]

26
27
28
# File 'lib/new_relic/agent/sampler.rb', line 26

def self.named(new_name)
  @shorthand_name = new_name
end

.sampler_classesObject

[View source]

48
49
50
# File 'lib/new_relic/agent/sampler.rb', line 48

def self.sampler_classes
  @sampler_classes
end

.supported_on_this_platform?Boolean

Override with check. Called before instantiating.

Returns:

  • (Boolean)
[View source]

35
36
37
# File 'lib/new_relic/agent/sampler.rb', line 35

def self.supported_on_this_platform?
  true
end

Instance Method Details

#pollObject

[View source]

59
60
61
# File 'lib/new_relic/agent/sampler.rb', line 59

def poll
  raise 'Implement in the subclass'
end