Class: TingYun::Agent::Collector::Sampler

Inherits:
Object
  • Object
show all
Defined in:
lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb

Direct Known Subclasses

CpuSampler, MemorySampler

Defined Under Namespace

Classes: Unsupported

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.



48
49
50
# File 'lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb', line 48

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb', line 12

def id
  @id
end

Class Method Details

.enabled?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
# File 'lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb', line 32

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

.inherited(subclass) ⇒ Object



23
24
25
# File 'lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb', line 23

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

.nameObject



19
20
21
# File 'lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb', line 19

def self.name
  @name
end

.named(new_name) ⇒ Object



15
16
17
# File 'lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb', line 15

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

.sampler_classesObject



41
42
43
# File 'lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb', line 41

def self.sampler_classes
  @sampler_classes
end

.supported_on_this_platform?Boolean

Override with check. Called before instantiating.

Returns:

  • (Boolean)


28
29
30
# File 'lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb', line 28

def self.supported_on_this_platform?
  true
end

Instance Method Details

#pollObject



52
53
54
# File 'lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb', line 52

def poll
  raise "Implement in the subclass"
end