metriks 0.9.7.3 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,10 +2,9 @@ source :rubygems
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rbtree'
6
-
7
5
  group :test do
8
6
  gem 'turn', '0.8.2', :require => false
9
7
  gem 'rake', '0.8.7'
10
- gem 'riemann-client', :platform => :mri_19
8
+ gem 'riemann-client', '~> 0.0.7'
9
+ gem 'rbtree', :platform => :mri_18
11
10
  end
@@ -2,6 +2,8 @@ require 'net/https'
2
2
 
3
3
  module Metriks::Reporter
4
4
  class LibratoMetrics
5
+ attr_accessor :prefix, :source
6
+
5
7
  def initialize(email, token, options = {})
6
8
  @email = email
7
9
  @token = token
@@ -2,6 +2,8 @@ require 'logger'
2
2
 
3
3
  module Metriks::Reporter
4
4
  class Logger
5
+ attr_accessor :prefix, :log_level, :logger
6
+
5
7
  def initialize(options = {})
6
8
  @logger = options[:logger] || ::Logger.new(STDOUT)
7
9
  @log_level = options[:log_level] || ::Logger::INFO
@@ -1,58 +1,59 @@
1
+ module Metriks
2
+ class Snapshot
3
+ MEDIAN_Q = 0.5
4
+ P75_Q = 0.75
5
+ P95_Q = 0.95
6
+ P98_Q = 0.98
7
+ P99_Q = 0.99
8
+ P999_Q = 0.999
1
9
 
2
- class Snapshot
3
- MEDIAN_Q = 0.5
4
- P75_Q = 0.75
5
- P95_Q = 0.95
6
- P98_Q = 0.98
7
- P99_Q = 0.99
8
- P999_Q = 0.999
10
+ attr_reader :values
9
11
 
10
- attr_reader :values
12
+ def initialize(values)
13
+ @values = values.sort
14
+ end
11
15
 
12
- def initialize(values)
13
- @values = values.sort
14
- end
16
+ def value(quantile)
17
+ raise ArgumentError, "quantile must be between 0.0 and 1.0" if quantile < 0.0 || quantile > 1.0
15
18
 
16
- def value(quantile)
17
- raise ArgumentError, "quantile must be between 0.0 and 1.0" if quantile < 0.0 || quantile > 1.0
19
+ return 0.0 if @values.empty?
18
20
 
19
- return 0.0 if @values.empty?
21
+ pos = quantile * (@values.length + 1)
20
22
 
21
- pos = quantile * (@values.length + 1)
23
+ return @values.first if pos < 1
24
+ return @values.last if pos >= @values.length
22
25
 
23
- return @values.first if pos < 1
24
- return @values.last if pos >= @values.length
26
+ lower = @values[pos.to_i - 1]
27
+ upper = @values[pos.to_i]
28
+ lower + (pos - pos.floor) * (upper - lower)
29
+ end
25
30
 
26
- lower = @values[pos.to_i - 1]
27
- upper = @values[pos.to_i]
28
- lower + (pos - pos.floor) * (upper - lower)
29
- end
31
+ def size
32
+ @values.length
33
+ end
30
34
 
31
- def size
32
- @values.length
33
- end
35
+ def median
36
+ value(MEDIAN_Q)
37
+ end
34
38
 
35
- def median
36
- value(MEDIAN_Q)
37
- end
39
+ def get_75th_percentile
40
+ value(P75_Q)
41
+ end
38
42
 
39
- def get_75th_percentile
40
- value(P75_Q)
41
- end
43
+ def get_95th_percentile
44
+ value(P95_Q)
45
+ end
42
46
 
43
- def get_95th_percentile
44
- value(P95_Q)
45
- end
46
-
47
- def get_98th_percentile
48
- value(P98_Q)
49
- end
47
+ def get_98th_percentile
48
+ value(P98_Q)
49
+ end
50
50
 
51
- def get_99th_percentile
52
- value(P99_Q)
53
- end
51
+ def get_99th_percentile
52
+ value(P99_Q)
53
+ end
54
54
 
55
- def get_999th_percentile
56
- value(P999_Q)
55
+ def get_999th_percentile
56
+ value(P999_Q)
57
+ end
57
58
  end
58
- end
59
+ end
data/lib/metriks.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Metriks
3
- VERSION = '0.9.7.3'
3
+ VERSION = '0.9.8'
4
4
 
5
5
  def self.get(name)
6
6
  Metriks::Registry.default.get(name)
data/metriks.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'metriks'
16
- s.version = '0.9.7.3'
17
- s.date = '2012-03-27'
16
+ s.version = '0.9.8'
17
+ s.date = '2012-04-25'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
@@ -1,9 +1,6 @@
1
1
  require 'test_helper'
2
2
  require 'thread_error_handling_tests'
3
3
 
4
- # riemann only works in 1.9
5
- if RUBY_VERSION > '1.9'
6
-
7
4
  require 'metriks/reporter/riemann'
8
5
 
9
6
  class RiemannReporterTest < Test::Unit::TestCase
@@ -72,5 +69,3 @@ class RiemannReporterTest < Test::Unit::TestCase
72
69
  @reporter.write
73
70
  end
74
71
  end
75
-
76
- end
metadata CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 7
9
- - 3
10
- version: 0.9.7.3
8
+ - 8
9
+ version: 0.9.8
11
10
  platform: ruby
12
11
  authors:
13
12
  - Eric Lindvall
@@ -15,13 +14,11 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2012-03-27 00:00:00 -07:00
17
+ date: 2012-04-25 00:00:00 -07:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: atomic
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
22
  requirements:
26
23
  - - ~>
27
24
  - !ruby/object:Gem::Version
@@ -29,12 +26,12 @@ dependencies:
29
26
  - 1
30
27
  - 0
31
28
  version: "1.0"
29
+ requirement: *id001
30
+ name: atomic
31
+ prerelease: false
32
32
  type: :runtime
33
- version_requirements: *id001
34
33
  - !ruby/object:Gem::Dependency
35
- name: hitimes
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
34
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
35
  requirements:
39
36
  - - ~>
40
37
  - !ruby/object:Gem::Version
@@ -42,12 +39,12 @@ dependencies:
42
39
  - 1
43
40
  - 1
44
41
  version: "1.1"
42
+ requirement: *id002
43
+ name: hitimes
44
+ prerelease: false
45
45
  type: :runtime
46
- version_requirements: *id002
47
46
  - !ruby/object:Gem::Dependency
48
- name: avl_tree
49
- prerelease: false
50
- requirement: &id003 !ruby/object:Gem::Requirement
47
+ version_requirements: &id003 !ruby/object:Gem::Requirement
51
48
  requirements:
52
49
  - - ~>
53
50
  - !ruby/object:Gem::Version
@@ -56,12 +53,12 @@ dependencies:
56
53
  - 1
57
54
  - 2
58
55
  version: 1.1.2
56
+ requirement: *id003
57
+ name: avl_tree
58
+ prerelease: false
59
59
  type: :runtime
60
- version_requirements: *id003
61
60
  - !ruby/object:Gem::Dependency
62
- name: mocha
63
- prerelease: false
64
- requirement: &id004 !ruby/object:Gem::Requirement
61
+ version_requirements: &id004 !ruby/object:Gem::Requirement
65
62
  requirements:
66
63
  - - ~>
67
64
  - !ruby/object:Gem::Version
@@ -69,8 +66,10 @@ dependencies:
69
66
  - 0
70
67
  - 10
71
68
  version: "0.10"
69
+ requirement: *id004
70
+ name: mocha
71
+ prerelease: false
72
72
  type: :development
73
- version_requirements: *id004
74
73
  description: An experimental metrics client.
75
74
  email: eric@sevenscale.com
76
75
  executables: []