Sha256: dc289e16a93440c1b737ff0cb82585688a37c5beb4ecdc8b6b2cad39d7b05364

Contents?: true

Size: 1.32 KB

Versions: 41

Compression:

Stored size: 1.32 KB

Contents

$: << File.join(File.absolute_path(__FILE__), '..', 'lib')

require 'pulse-meter'
PulseMeter.redis = Redis.new

# static sensor examples

counter = PulseMeter::Sensor::Counter.new :my_counter
counter.event(1)
counter.event(2)
puts counter.value

indicator = PulseMeter::Sensor::Indicator.new :my_value
indicator.event(3.14)
indicator.event(2.71)
puts indicator.value

hashed_counter = PulseMeter::Sensor::HashedCounter.new :my_h_counter
hashed_counter.event(:x => 1)
hashed_counter.event(:y => 5)
hashed_counter.event(:y => 1)
p hashed_counter.value


# timeline sensor examples

requests_per_minute = PulseMeter::Sensor::Timelined::Counter.new(:my_t_counter,
  :interval => 60,         # count for each minute
  :ttl => 24 * 60 * 60     # keep data one day
)
requests_per_minute.event(1)
requests_per_minute.event(1)
sleep(60)
requests_per_minute.event(1)
requests_per_minute.timeline(2 * 60).each do |v|
  puts "#{v.start_time}: #{v.value}"
end

max_per_minute = PulseMeter::Sensor::Timelined::Max.new(:my_t_max,
  :interval => 60,         # max for each minute
  :ttl => 24 * 60 * 60     # keep data one day
)
max_per_minute.event(3)
max_per_minute.event(1)
max_per_minute.event(2)
sleep(60)
max_per_minute.event(5)
max_per_minute.event(7)
max_per_minute.event(6)
max_per_minute.timeline(2 * 60).each do |v|
  puts "#{v.start_time}: #{v.value}"
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
pulse-meter-0.4.14 examples/readme_client.rb
pulse-meter-0.4.12 examples/readme_client.rb
pulse-meter-0.4.11 examples/readme_client.rb
pulse-meter-0.4.9 examples/readme_client.rb
pulse-meter-0.4.8 examples/readme_client.rb
pulse-meter-0.4.7 examples/readme_client.rb
pulse-meter-0.4.6 examples/readme_client.rb
pulse-meter-0.4.5 examples/readme_client.rb
pulse-meter-0.4.4 examples/readme_client.rb
pulse-meter-0.4.3 examples/readme_client.rb
pulse-meter-0.4.2 examples/readme_client.rb
pulse-meter-0.4.1 examples/readme_client.rb
pulse-meter-0.4.0 examples/readme_client.rb
pulse-meter-0.3.2 examples/readme_client.rb
pulse-meter-0.3.1 examples/readme_client.rb
pulse-meter-0.3.0 examples/readme_client.rb
pulse-meter-0.2.11 examples/readme_client.rb
pulse-meter-0.2.10 examples/readme_client.rb
pulse-meter-0.2.9 examples/readme_client.rb
pulse-meter-0.2.8 examples/readme_client.rb