appoptics-api-ruby 2.1.3
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/.gitignore +23 -0
- data/.rspec +2 -0
- data/.travis.yml +25 -0
- data/CHANGELOG.md +184 -0
- data/Gemfile +36 -0
- data/LICENSE +24 -0
- data/README.md +271 -0
- data/Rakefile +63 -0
- data/appoptics-api-ruby.gemspec +31 -0
- data/benchmarks/array_vs_set.rb +29 -0
- data/certs/librato-public.pem +20 -0
- data/examples/simple.rb +24 -0
- data/examples/submit_every.rb +27 -0
- data/lib/appoptics/metrics.rb +95 -0
- data/lib/appoptics/metrics/aggregator.rb +138 -0
- data/lib/appoptics/metrics/annotator.rb +145 -0
- data/lib/appoptics/metrics/client.rb +361 -0
- data/lib/appoptics/metrics/collection.rb +43 -0
- data/lib/appoptics/metrics/connection.rb +101 -0
- data/lib/appoptics/metrics/errors.rb +32 -0
- data/lib/appoptics/metrics/middleware/count_requests.rb +28 -0
- data/lib/appoptics/metrics/middleware/expects_status.rb +38 -0
- data/lib/appoptics/metrics/middleware/request_body.rb +18 -0
- data/lib/appoptics/metrics/middleware/retry.rb +31 -0
- data/lib/appoptics/metrics/persistence.rb +2 -0
- data/lib/appoptics/metrics/persistence/direct.rb +73 -0
- data/lib/appoptics/metrics/persistence/test.rb +27 -0
- data/lib/appoptics/metrics/processor.rb +130 -0
- data/lib/appoptics/metrics/queue.rb +191 -0
- data/lib/appoptics/metrics/smart_json.rb +43 -0
- data/lib/appoptics/metrics/util.rb +25 -0
- data/lib/appoptics/metrics/version.rb +5 -0
- data/spec/integration/metrics/annotator_spec.rb +190 -0
- data/spec/integration/metrics/connection_spec.rb +14 -0
- data/spec/integration/metrics/middleware/count_requests_spec.rb +28 -0
- data/spec/integration/metrics/queue_spec.rb +96 -0
- data/spec/integration/metrics_spec.rb +375 -0
- data/spec/rackups/status.ru +30 -0
- data/spec/spec_helper.rb +88 -0
- data/spec/unit/metrics/aggregator_spec.rb +417 -0
- data/spec/unit/metrics/client_spec.rb +127 -0
- data/spec/unit/metrics/connection_spec.rb +113 -0
- data/spec/unit/metrics/queue/autosubmission_spec.rb +57 -0
- data/spec/unit/metrics/queue_spec.rb +593 -0
- data/spec/unit/metrics/smart_json_spec.rb +79 -0
- data/spec/unit/metrics/util_spec.rb +23 -0
- data/spec/unit/metrics_spec.rb +63 -0
- metadata +135 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Appoptics
|
|
4
|
+
module Metrics
|
|
5
|
+
|
|
6
|
+
describe SmartJSON do
|
|
7
|
+
|
|
8
|
+
describe ".read" do
|
|
9
|
+
context "with MultiJSON" do
|
|
10
|
+
before do
|
|
11
|
+
$".delete_if {|s| s.include?("multi_json")}
|
|
12
|
+
require "multi_json"
|
|
13
|
+
load "lib/appoptics/metrics/smart_json.rb"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
after do
|
|
17
|
+
Object.send(:remove_const, :MultiJson)
|
|
18
|
+
load "lib/appoptics/metrics/smart_json.rb"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "uses .load or .decode" do
|
|
22
|
+
actual = SmartJSON.read("{\"abc\":\"def\"}")
|
|
23
|
+
|
|
24
|
+
expect(SmartJSON.handler).to eq(:multi_json)
|
|
25
|
+
expect(actual).to be_a(Hash)
|
|
26
|
+
expect(actual).to have_key("abc")
|
|
27
|
+
expect(actual["abc"]).to eq("def")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "with JSON" do
|
|
32
|
+
it "uses .parse" do
|
|
33
|
+
actual = SmartJSON.read("{\"abc\":\"def\"}")
|
|
34
|
+
|
|
35
|
+
expect(SmartJSON.handler).to eq(:json)
|
|
36
|
+
expect(actual).to be_a(Hash)
|
|
37
|
+
expect(actual).to have_key("abc")
|
|
38
|
+
expect(actual["abc"]).to eq("def")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe ".write" do
|
|
44
|
+
context "with MultiJSON" do
|
|
45
|
+
before do
|
|
46
|
+
$".delete_if {|s| s.include?("multi_json")}
|
|
47
|
+
require "multi_json"
|
|
48
|
+
load "lib/appoptics/metrics/smart_json.rb"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
after do
|
|
52
|
+
Object.send(:remove_const, :MultiJson)
|
|
53
|
+
load "lib/appoptics/metrics/smart_json.rb"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "uses .dump or .decode" do
|
|
57
|
+
actual = SmartJSON.write({abc: 'def'})
|
|
58
|
+
|
|
59
|
+
expect(SmartJSON.handler).to eq(:multi_json)
|
|
60
|
+
expect(actual).to be_a(String)
|
|
61
|
+
expect(actual).to eq("{\"abc\":\"def\"}")
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
context "with JSON" do
|
|
66
|
+
it "uses .generate" do
|
|
67
|
+
actual = SmartJSON.write({abc: 'def'})
|
|
68
|
+
|
|
69
|
+
expect(SmartJSON.handler).to eq(:json)
|
|
70
|
+
expect(actual).to be_a(String)
|
|
71
|
+
expect(actual).to eq("{\"abc\":\"def\"}")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Appoptics
|
|
4
|
+
module Metrics
|
|
5
|
+
|
|
6
|
+
describe Util do
|
|
7
|
+
|
|
8
|
+
describe "#build_key_for" do
|
|
9
|
+
it "builds a Hash key" do
|
|
10
|
+
metric_name = "requests"
|
|
11
|
+
tags = { status: 200, MeThoD: "GET", controller: "users", ACTION: "show" }
|
|
12
|
+
expected = "requests%%action=show%%method=get%%controller=users%%status=200"
|
|
13
|
+
actual = Util.build_key_for(metric_name, tags)
|
|
14
|
+
|
|
15
|
+
expect(expected).to eq(actual)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Appoptics
|
|
4
|
+
|
|
5
|
+
describe Metrics do
|
|
6
|
+
|
|
7
|
+
describe "#authorize" do
|
|
8
|
+
context "when given two arguments" do
|
|
9
|
+
it "stores them on simple" do
|
|
10
|
+
Metrics.authenticate 'api_key'
|
|
11
|
+
expect(Metrics.client.api_key).to eq('api_key')
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "#faraday_adapter" do
|
|
17
|
+
it "returns current default adapter" do
|
|
18
|
+
expect(Metrics.faraday_adapter).not_to be_nil
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "#faraday_adapter=" do
|
|
23
|
+
before(:all) { @current_adapter = Metrics.faraday_adapter }
|
|
24
|
+
after(:all) { Metrics.faraday_adapter = @current_adapter }
|
|
25
|
+
|
|
26
|
+
it "allows setting of faraday adapter" do
|
|
27
|
+
Metrics.faraday_adapter = :excon
|
|
28
|
+
expect(Metrics.faraday_adapter).to eq(:excon)
|
|
29
|
+
Metrics.faraday_adapter = :patron
|
|
30
|
+
expect(Metrics.faraday_adapter).to eq(:patron)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "#persistence" do
|
|
35
|
+
it "allows configuration of persistence method" do
|
|
36
|
+
Metrics.persistence = :test
|
|
37
|
+
expect(Metrics.persistence).to eq(:test)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe "#submit" do
|
|
42
|
+
before(:all) do
|
|
43
|
+
Appoptics::Metrics.persistence = :test
|
|
44
|
+
Appoptics::Metrics.authenticate 'me@AppOptics.com', 'foo'
|
|
45
|
+
end
|
|
46
|
+
after(:all) { Appoptics::Metrics.client.flush_authentication }
|
|
47
|
+
|
|
48
|
+
it "persists metrics immediately" do
|
|
49
|
+
Metrics.persistence = :test
|
|
50
|
+
expect(Metrics.submit(foo: 123)).to be true
|
|
51
|
+
expect(Metrics.persister.persisted).to eq({gauges: [{name: 'foo', value: 123}]})
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "tolerates multiple metrics" do
|
|
55
|
+
expect { Appoptics::Metrics.submit foo: 123, bar: 456 }.not_to raise_error
|
|
56
|
+
expected = {gauges: [{name: 'foo', value: 123}, {name: 'bar', value: 456}]}
|
|
57
|
+
expect(Appoptics::Metrics.persister.persisted).to equal_unordered(expected)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: appoptics-api-ruby
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 2.1.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Greg McKeever
|
|
8
|
+
- Matt Sanders
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain:
|
|
12
|
+
- certs/appoptics-public.pem
|
|
13
|
+
date: 2017-10-13 00:00:00.000000000 Z
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: faraday
|
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
|
18
|
+
requirements:
|
|
19
|
+
- - ">="
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '0'
|
|
29
|
+
- !ruby/object:Gem::Dependency
|
|
30
|
+
name: aggregate
|
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - "~>"
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: 0.2.2
|
|
36
|
+
type: :runtime
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - "~>"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 0.2.2
|
|
43
|
+
description: An easy to use ruby wrapper for the AppOptics API
|
|
44
|
+
email: greg@solarwinds.cloud
|
|
45
|
+
executables: []
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- ".gitignore"
|
|
50
|
+
- ".rspec"
|
|
51
|
+
- ".travis.yml"
|
|
52
|
+
- CHANGELOG.md
|
|
53
|
+
- Gemfile
|
|
54
|
+
- LICENSE
|
|
55
|
+
- README.md
|
|
56
|
+
- Rakefile
|
|
57
|
+
- appoptics-api-ruby.gemspec
|
|
58
|
+
- benchmarks/array_vs_set.rb
|
|
59
|
+
- certs/librato-public.pem
|
|
60
|
+
- examples/simple.rb
|
|
61
|
+
- examples/submit_every.rb
|
|
62
|
+
- lib/appoptics/metrics.rb
|
|
63
|
+
- lib/appoptics/metrics/aggregator.rb
|
|
64
|
+
- lib/appoptics/metrics/annotator.rb
|
|
65
|
+
- lib/appoptics/metrics/client.rb
|
|
66
|
+
- lib/appoptics/metrics/collection.rb
|
|
67
|
+
- lib/appoptics/metrics/connection.rb
|
|
68
|
+
- lib/appoptics/metrics/errors.rb
|
|
69
|
+
- lib/appoptics/metrics/middleware/count_requests.rb
|
|
70
|
+
- lib/appoptics/metrics/middleware/expects_status.rb
|
|
71
|
+
- lib/appoptics/metrics/middleware/request_body.rb
|
|
72
|
+
- lib/appoptics/metrics/middleware/retry.rb
|
|
73
|
+
- lib/appoptics/metrics/persistence.rb
|
|
74
|
+
- lib/appoptics/metrics/persistence/direct.rb
|
|
75
|
+
- lib/appoptics/metrics/persistence/test.rb
|
|
76
|
+
- lib/appoptics/metrics/processor.rb
|
|
77
|
+
- lib/appoptics/metrics/queue.rb
|
|
78
|
+
- lib/appoptics/metrics/smart_json.rb
|
|
79
|
+
- lib/appoptics/metrics/util.rb
|
|
80
|
+
- lib/appoptics/metrics/version.rb
|
|
81
|
+
- spec/integration/metrics/annotator_spec.rb
|
|
82
|
+
- spec/integration/metrics/connection_spec.rb
|
|
83
|
+
- spec/integration/metrics/middleware/count_requests_spec.rb
|
|
84
|
+
- spec/integration/metrics/queue_spec.rb
|
|
85
|
+
- spec/integration/metrics_spec.rb
|
|
86
|
+
- spec/rackups/status.ru
|
|
87
|
+
- spec/spec_helper.rb
|
|
88
|
+
- spec/unit/metrics/aggregator_spec.rb
|
|
89
|
+
- spec/unit/metrics/client_spec.rb
|
|
90
|
+
- spec/unit/metrics/connection_spec.rb
|
|
91
|
+
- spec/unit/metrics/queue/autosubmission_spec.rb
|
|
92
|
+
- spec/unit/metrics/queue_spec.rb
|
|
93
|
+
- spec/unit/metrics/smart_json_spec.rb
|
|
94
|
+
- spec/unit/metrics/util_spec.rb
|
|
95
|
+
- spec/unit/metrics_spec.rb
|
|
96
|
+
homepage: https://github.com/AppOptics/appoptics-api-ruby
|
|
97
|
+
licenses:
|
|
98
|
+
- BSD 3-clause
|
|
99
|
+
metadata: {}
|
|
100
|
+
post_install_message:
|
|
101
|
+
rdoc_options: []
|
|
102
|
+
require_paths:
|
|
103
|
+
- lib
|
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - ">="
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '0'
|
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '0'
|
|
114
|
+
requirements: []
|
|
115
|
+
rubyforge_project:
|
|
116
|
+
rubygems_version: 2.5.1
|
|
117
|
+
signing_key:
|
|
118
|
+
specification_version: 4
|
|
119
|
+
summary: Ruby bindings for the AppOptics API
|
|
120
|
+
test_files:
|
|
121
|
+
- spec/integration/metrics/annotator_spec.rb
|
|
122
|
+
- spec/integration/metrics/connection_spec.rb
|
|
123
|
+
- spec/integration/metrics/middleware/count_requests_spec.rb
|
|
124
|
+
- spec/integration/metrics/queue_spec.rb
|
|
125
|
+
- spec/integration/metrics_spec.rb
|
|
126
|
+
- spec/rackups/status.ru
|
|
127
|
+
- spec/spec_helper.rb
|
|
128
|
+
- spec/unit/metrics/aggregator_spec.rb
|
|
129
|
+
- spec/unit/metrics/client_spec.rb
|
|
130
|
+
- spec/unit/metrics/connection_spec.rb
|
|
131
|
+
- spec/unit/metrics/queue/autosubmission_spec.rb
|
|
132
|
+
- spec/unit/metrics/queue_spec.rb
|
|
133
|
+
- spec/unit/metrics/smart_json_spec.rb
|
|
134
|
+
- spec/unit/metrics/util_spec.rb
|
|
135
|
+
- spec/unit/metrics_spec.rb
|