statsn 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/statsn.rb +7 -2
- data/lib/statsn/version.rb +1 -1
- metadata +15 -36
- data/.gitignore +0 -1
- data/.travis.yml +0 -4
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -36
- data/Rakefile +0 -6
- data/Readme.md +0 -55
- data/spec/argv.example.yml +0 -4
- data/spec/spec_helper.rb +0 -3
- data/spec/statsn_calls_spec.rb +0 -56
- data/spec/statsn_spec.rb +0 -69
- data/statsn.gemspec +0 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3f16081e04616c5af953ba9a304c5515eb5e18ba
|
4
|
+
data.tar.gz: e27df826af67a56b23eb0108cf7337473f55c747
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 17392b96a6b618b49984f5e39a3f8991eb2ea938d216b7229f8712143bcb0845609638410bef753ae8d38f03aef927d9ad3dbab38d303215ef0ac8644fcab1b0
|
7
|
+
data.tar.gz: 97ac5174c2e362c9d25948a89d42a978e8273d8befa41a52d68e19e52dc611679e935e4a790119bf20f82341cf301836370a5dc4161efc2a0e8167dad56aa1d9
|
data/lib/statsn.rb
CHANGED
@@ -26,8 +26,13 @@ module Statsn
|
|
26
26
|
def key(who)
|
27
27
|
if who.is_a?(Array)
|
28
28
|
model = who.first
|
29
|
-
model =
|
30
|
-
|
29
|
+
model = case model
|
30
|
+
when String then model
|
31
|
+
when Class then model.name
|
32
|
+
else
|
33
|
+
model.class.name
|
34
|
+
end
|
35
|
+
[PREFIX, model.gsub("::", "/"), *who[1..-1]].compact.join("/")
|
31
36
|
else
|
32
37
|
who
|
33
38
|
end
|
data/lib/statsn/version.rb
CHANGED
metadata
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.1
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Michael Grosser
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
14
|
+
name: newrelic_rpm
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.5'
|
20
|
-
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
|
-
|
23
|
-
requirement: !ruby/object:Gem::Requirement
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
|
-
- - ~>
|
24
|
+
- - "~>"
|
26
25
|
- !ruby/object:Gem::Version
|
27
26
|
version: '3.5'
|
28
|
-
none: false
|
29
|
-
type: :runtime
|
30
27
|
description:
|
31
28
|
email: michael@grosser.it
|
32
29
|
executables:
|
@@ -34,49 +31,31 @@ executables:
|
|
34
31
|
extensions: []
|
35
32
|
extra_rdoc_files: []
|
36
33
|
files:
|
37
|
-
- .gitignore
|
38
|
-
- .travis.yml
|
39
|
-
- Gemfile
|
40
|
-
- Gemfile.lock
|
41
|
-
- Rakefile
|
42
|
-
- Readme.md
|
43
34
|
- bin/statsn-calls
|
44
35
|
- lib/statsn.rb
|
45
36
|
- lib/statsn/version.rb
|
46
|
-
|
47
|
-
- spec/spec_helper.rb
|
48
|
-
- spec/statsn_calls_spec.rb
|
49
|
-
- spec/statsn_spec.rb
|
50
|
-
- statsn.gemspec
|
51
|
-
homepage: http://github.com/grosser/statsn
|
37
|
+
homepage: https://github.com/grosser/statsn
|
52
38
|
licenses:
|
53
39
|
- MIT
|
40
|
+
metadata: {}
|
54
41
|
post_install_message:
|
55
42
|
rdoc_options: []
|
56
43
|
require_paths:
|
57
44
|
- lib
|
58
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
46
|
requirements:
|
60
|
-
- -
|
47
|
+
- - ">="
|
61
48
|
- !ruby/object:Gem::Version
|
62
49
|
version: '0'
|
63
|
-
segments:
|
64
|
-
- 0
|
65
|
-
hash: 2968399290205698663
|
66
|
-
none: false
|
67
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
51
|
requirements:
|
69
|
-
- -
|
52
|
+
- - ">="
|
70
53
|
- !ruby/object:Gem::Version
|
71
54
|
version: '0'
|
72
|
-
segments:
|
73
|
-
- 0
|
74
|
-
hash: 2968399290205698663
|
75
|
-
none: false
|
76
55
|
requirements: []
|
77
56
|
rubyforge_project:
|
78
|
-
rubygems_version:
|
57
|
+
rubygems_version: 2.2.2
|
79
58
|
signing_key:
|
80
|
-
specification_version:
|
81
|
-
summary:
|
59
|
+
specification_version: 4
|
60
|
+
summary: 'StatsN: Aggregate statistics using newrelics custom metrics'
|
82
61
|
test_files: []
|
data/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
spec/argv.yml
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
statsn (0.1.1)
|
5
|
-
newrelic_rpm (~> 3.5)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
bump (0.3.7)
|
11
|
-
diff-lcs (1.1.3)
|
12
|
-
faraday (0.8.4)
|
13
|
-
multipart-post (~> 1.1)
|
14
|
-
json (1.7.5)
|
15
|
-
multipart-post (1.1.5)
|
16
|
-
newrelic_rpm (3.5.3.25)
|
17
|
-
rake (0.9.2)
|
18
|
-
rspec (2.6.0)
|
19
|
-
rspec-core (~> 2.6.0)
|
20
|
-
rspec-expectations (~> 2.6.0)
|
21
|
-
rspec-mocks (~> 2.6.0)
|
22
|
-
rspec-core (2.6.4)
|
23
|
-
rspec-expectations (2.6.0)
|
24
|
-
diff-lcs (~> 1.1.2)
|
25
|
-
rspec-mocks (2.6.0)
|
26
|
-
|
27
|
-
PLATFORMS
|
28
|
-
ruby
|
29
|
-
|
30
|
-
DEPENDENCIES
|
31
|
-
bump
|
32
|
-
faraday
|
33
|
-
json
|
34
|
-
rake
|
35
|
-
rspec (~> 2)
|
36
|
-
statsn!
|
data/Rakefile
DELETED
data/Readme.md
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
StatsN: Aggregate statistics using NewRelic's custom metrics.
|
2
|
-
|
3
|
-
Install
|
4
|
-
=======
|
5
|
-
|
6
|
-
gem install statsn
|
7
|
-
|
8
|
-
Usage
|
9
|
-
=====
|
10
|
-
|
11
|
-
### Track
|
12
|
-
|
13
|
-
require "statsn"
|
14
|
-
|
15
|
-
Statsn.increment("Custom/Xyz") -> tracked as "Custom/Xyz"
|
16
|
-
Statsn.increment([Abc::Xyz, "update"]) -> tracked as "Custom/Abc/Xyz/update"
|
17
|
-
Statsn.increment([self, "update"]) -> tracked as "Custom/<class-you-are-in>/update"
|
18
|
-
|
19
|
-
Statsn.increment("Custom/Xyz", 5) -> increment by 5
|
20
|
-
|
21
|
-
Statsn.time("Custom/Abc") do
|
22
|
-
sleep 1
|
23
|
-
end
|
24
|
-
|
25
|
-
### Analyze
|
26
|
-
|
27
|
-
# show all metrics and fields
|
28
|
-
curl -H "x-api-key:API_KEY" https://api.newrelic.com/api/v1/applications/12345/metrics.json -> list of all metrics and fields
|
29
|
-
|
30
|
-
gem install faraday json
|
31
|
-
|
32
|
-
# statsn-calls API-KEY ACCOUNT-ID APPLICATION-ID METRIC-NAME
|
33
|
-
statsn-calls asdhgjasdgjhdasjgahsdasdjghsdjhg 123 1234567 Controller/users/index
|
34
|
-
|
35
|
-
call_count: 274909.0
|
36
|
-
total_call_time: 37585.77862974794
|
37
|
-
response time: 0.1367208008095331
|
38
|
-
call per second: 3.18181712962963
|
39
|
-
|
40
|
-
# statsn-calls API-KEY ACCOUNT-ID APPLICATION-ID METRIC-NAME-PREFIX
|
41
|
-
statsn-calls asdhgjasdgjhdasjgahsdasdjghsdjhg 123 1234567 Controller/users/*
|
42
|
-
|
43
|
-
call_count: 287300.0
|
44
|
-
total_call_time: 39330.15688060733
|
45
|
-
response time: 0.13689577751690682
|
46
|
-
call per second: 3.3252314814814814
|
47
|
-
|
48
|
-
Author
|
49
|
-
======
|
50
|
-
Original version by [Morten Primdahl](https://github.com/morten)<br/>
|
51
|
-
|
52
|
-
[Michael Grosser](http://grosser.it)<br/>
|
53
|
-
michael@grosser.it<br/>
|
54
|
-
License: MIT<br/>
|
55
|
-
[](https://travis-ci.org/grosser/statsn)
|
data/spec/argv.example.yml
DELETED
data/spec/spec_helper.rb
DELETED
data/spec/statsn_calls_spec.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "statsn-calls" do
|
4
|
-
let(:argv){ YAML.load File.read("#{Bundler.root}/spec/argv.yml") }
|
5
|
-
|
6
|
-
before do
|
7
|
-
pending "create a spec/argv.yml" unless (argv rescue nil)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "gives us some numbers" do
|
11
|
-
result = run argv["single"]
|
12
|
-
result.should =~ /^call_count: \d+/
|
13
|
-
result.should =~ /^total_call_time: \d+/
|
14
|
-
result.should =~ /^response time: \d+/
|
15
|
-
result.should =~ /^call per second: \d+/
|
16
|
-
end
|
17
|
-
|
18
|
-
it "gives us some numbers for a prefix call" do
|
19
|
-
result = run argv["multi"]
|
20
|
-
result.should =~ /^call_count: \d+/
|
21
|
-
result.should =~ /^total_call_time: \d+/
|
22
|
-
result.should =~ /^response time: \d+/
|
23
|
-
result.should =~ /^call per second: \d+/
|
24
|
-
end
|
25
|
-
|
26
|
-
it "shows help" do
|
27
|
-
result = run("--help")
|
28
|
-
result.should include("statsn-calls API-KEY")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "shows help and fail with invalid args" do
|
32
|
-
result = run("asdadsasdasd", :fail => true)
|
33
|
-
result.should include("statsn-calls API-KEY")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "show data for count-only metrics" do
|
37
|
-
result = run argv["count"]
|
38
|
-
result.should =~ /^call_count: \d+/
|
39
|
-
result.should_not =~ /^total_call_time: \d+/
|
40
|
-
result.should_not =~ /^response time: \d+/
|
41
|
-
result.should =~ /^call per second: \d+/
|
42
|
-
end
|
43
|
-
|
44
|
-
it "tell us if the metric is missing" do
|
45
|
-
result = run("#{argv["single"]}/xxxx", :fail => true)
|
46
|
-
result.should include("No data found for Controller/")
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def run(argv, options={})
|
52
|
-
result = `ruby -I #{Bundler.root}/lib #{Bundler.root}/bin/statsn-calls #{argv} 2>&1`
|
53
|
-
raise "FAILED: #{result}" if $?.success? == !!options[:fail]
|
54
|
-
result
|
55
|
-
end
|
56
|
-
end
|
data/spec/statsn_spec.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module Foobar
|
4
|
-
class TestClass
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
describe Statsn do
|
9
|
-
it "has a VERSION" do
|
10
|
-
Statsn::VERSION.should =~ /^[\.\da-z]+$/
|
11
|
-
end
|
12
|
-
|
13
|
-
describe ".increment" do
|
14
|
-
it "calls count api with 1" do
|
15
|
-
NewRelic::MethodTraceStats.any_instance.should_receive(:record_data_point).with(1)
|
16
|
-
Statsn.increment("xxx")
|
17
|
-
end
|
18
|
-
|
19
|
-
it "calls count api with given number" do
|
20
|
-
NewRelic::MethodTraceStats.any_instance.should_receive(:record_data_point).with(3)
|
21
|
-
Statsn.increment("xxx", 3)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe ".time" do
|
26
|
-
before do
|
27
|
-
NewRelic::Agent.is_execution_traced?.should == true
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns block result" do
|
31
|
-
Statsn.time("xxx"){ 4 }.should == 4
|
32
|
-
end
|
33
|
-
|
34
|
-
it "raises errors" do
|
35
|
-
expect{
|
36
|
-
Statsn.time("xxx"){ raise EOFError }
|
37
|
-
}.to raise_error(EOFError)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "records used time" do
|
41
|
-
NewRelic::MethodTraceStats.any_instance.should_receive(:trace_call).with{|x| x.should be_within(0.05).of(0.1) }
|
42
|
-
Statsn.time("xxx"){ sleep 0.1 }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe ".data" do
|
47
|
-
it "returns data for metrics" do
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe ".key" do
|
53
|
-
it "builds with a string" do
|
54
|
-
Statsn.send(:key, "xxx").should == "xxx"
|
55
|
-
end
|
56
|
-
|
57
|
-
it "builds with a class and name" do
|
58
|
-
Statsn.send(:key, [Foobar::TestClass, "xxx"]).should == "Custom/Foobar/TestClass/xxx"
|
59
|
-
end
|
60
|
-
|
61
|
-
it "builds with an instance and name" do
|
62
|
-
Statsn.send(:key, [Foobar::TestClass.new, "xxx"]).should == "Custom/Foobar/TestClass/xxx"
|
63
|
-
end
|
64
|
-
|
65
|
-
it "ignores nil" do
|
66
|
-
Statsn.send(:key, [Foobar::TestClass, nil, nil, "xxx"]).should == "Custom/Foobar/TestClass/xxx"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
data/statsn.gemspec
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
|
-
name = "statsn"
|
3
|
-
require "#{name}/version"
|
4
|
-
|
5
|
-
Gem::Specification.new name, Statsn::VERSION do |s|
|
6
|
-
s.summary = "StatsN: Aggregate statistics using newrelics custom metrics"
|
7
|
-
s.authors = ["Michael Grosser"]
|
8
|
-
s.email = "michael@grosser.it"
|
9
|
-
s.homepage = "http://github.com/grosser/#{name}"
|
10
|
-
s.files = `git ls-files`.split("\n")
|
11
|
-
s.license = "MIT"
|
12
|
-
s.executables = ["statsn-calls"]
|
13
|
-
s.add_runtime_dependency "newrelic_rpm", "~> 3.5"
|
14
|
-
end
|