metriks-derive 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +22 -0
- data/Rakefile +2 -0
- data/lib/metriks-derive.rb +38 -0
- data/metriks-derive.gemspec +16 -0
- metadata +53 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Benedikt Böhm
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Metriks::Derive
|
2
|
+
|
3
|
+
Metriks::Derive is a derivative metric for the Metriks gem.
|
4
|
+
|
5
|
+
A derivative metric is like a meter but accepts an absolute counter as input.
|
6
|
+
This is useful for metrics like bytes sent over the network or cpu cycles which
|
7
|
+
are generally monotonically increasing counters and therefore need to be
|
8
|
+
derived from the previous sample to get a useful rate/s value.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'metriks-derive'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install metriks-derive
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'atomic'
|
2
|
+
require 'metriks'
|
3
|
+
|
4
|
+
module Metriks
|
5
|
+
def self.derive(name)
|
6
|
+
Metriks::Registry.default.derive(name)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Metriks
|
11
|
+
class Registry
|
12
|
+
|
13
|
+
# Public: Fetch or create a new derivative metric. Derivatives are a meter
|
14
|
+
# that tracks throughput by calculating the derivative to the previous
|
15
|
+
# value.
|
16
|
+
#
|
17
|
+
# name - The String name of the metric to define or fetch
|
18
|
+
#
|
19
|
+
# Examples
|
20
|
+
#
|
21
|
+
# registry.derive('network.bytes')
|
22
|
+
#
|
23
|
+
# Returns the Metricks::Derive identified by the name.
|
24
|
+
def derive(name)
|
25
|
+
add_or_get(name, Metriks::Derive)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module Metriks
|
31
|
+
class Derive < Metriks::Meter
|
32
|
+
def mark(val = 1)
|
33
|
+
@last ||= Atomic.new(val)
|
34
|
+
last = @last.swap(val)
|
35
|
+
super(last > val ? val : val - last)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Benedikt Böhm"]
|
5
|
+
gem.email = ["bb@xnull.de"]
|
6
|
+
gem.description = %q{A derivative metric for the Metriks gem}
|
7
|
+
gem.summary = %q{A derivative metric for the Metriks gem}
|
8
|
+
gem.homepage = "https://github.com/zenops/metriks-derive"
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "metriks-derive"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = "0.1.0"
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: metriks-derive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Benedikt Böhm
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A derivative metric for the Metriks gem
|
15
|
+
email:
|
16
|
+
- bb@xnull.de
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/metriks-derive.rb
|
27
|
+
- metriks-derive.gemspec
|
28
|
+
homepage: https://github.com/zenops/metriks-derive
|
29
|
+
licenses: []
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 1.8.24
|
49
|
+
signing_key:
|
50
|
+
specification_version: 3
|
51
|
+
summary: A derivative metric for the Metriks gem
|
52
|
+
test_files: []
|
53
|
+
has_rdoc:
|