wavefront-sdk 3.3.3 → 3.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -17
- data/Gemfile +2 -0
- data/HISTORY.md +4 -0
- data/Rakefile +2 -0
- data/lib/wavefront-sdk/alert.rb +5 -2
- data/lib/wavefront-sdk/api_mixins/acl.rb +3 -0
- data/lib/wavefront-sdk/api_mixins/tag.rb +2 -0
- data/lib/wavefront-sdk/api_mixins/user.rb +4 -0
- data/lib/wavefront-sdk/apitoken.rb +2 -0
- data/lib/wavefront-sdk/cloudintegration.rb +4 -0
- data/lib/wavefront-sdk/core/api.rb +3 -0
- data/lib/wavefront-sdk/core/api_caller.rb +16 -10
- data/lib/wavefront-sdk/core/exception.rb +2 -0
- data/lib/wavefront-sdk/core/logger.rb +6 -3
- data/lib/wavefront-sdk/core/response.rb +6 -3
- data/lib/wavefront-sdk/credentials.rb +5 -2
- data/lib/wavefront-sdk/dashboard.rb +3 -0
- data/lib/wavefront-sdk/defs/constants.rb +3 -1
- data/lib/wavefront-sdk/defs/version.rb +3 -1
- data/lib/wavefront-sdk/derivedmetric.rb +3 -0
- data/lib/wavefront-sdk/distribution.rb +36 -16
- data/lib/wavefront-sdk/event.rb +16 -12
- data/lib/wavefront-sdk/externallink.rb +3 -0
- data/lib/wavefront-sdk/integration.rb +2 -0
- data/lib/wavefront-sdk/maintenancewindow.rb +4 -1
- data/lib/wavefront-sdk/message.rb +2 -0
- data/lib/wavefront-sdk/metric.rb +3 -0
- data/lib/wavefront-sdk/metric_helper.rb +6 -4
- data/lib/wavefront-sdk/notificant.rb +3 -0
- data/lib/wavefront-sdk/paginator/base.rb +5 -0
- data/lib/wavefront-sdk/paginator/delete.rb +2 -0
- data/lib/wavefront-sdk/paginator/get.rb +2 -0
- data/lib/wavefront-sdk/paginator/post.rb +2 -0
- data/lib/wavefront-sdk/paginator/put.rb +2 -0
- data/lib/wavefront-sdk/proxy.rb +2 -0
- data/lib/wavefront-sdk/query.rb +6 -3
- data/lib/wavefront-sdk/report.rb +2 -0
- data/lib/wavefront-sdk/savedsearch.rb +4 -0
- data/lib/wavefront-sdk/search.rb +4 -1
- data/lib/wavefront-sdk/settings.rb +2 -0
- data/lib/wavefront-sdk/source.rb +3 -0
- data/lib/wavefront-sdk/stdlib/array.rb +2 -0
- data/lib/wavefront-sdk/stdlib/hash.rb +5 -1
- data/lib/wavefront-sdk/stdlib/string.rb +2 -0
- data/lib/wavefront-sdk/support/mixins.rb +5 -1
- data/lib/wavefront-sdk/support/parse_time.rb +3 -0
- data/lib/wavefront-sdk/types/status.rb +4 -0
- data/lib/wavefront-sdk/user.rb +18 -8
- data/lib/wavefront-sdk/usergroup.rb +3 -0
- data/lib/wavefront-sdk/validators.rb +28 -0
- data/lib/wavefront-sdk/webhook.rb +3 -0
- data/lib/wavefront-sdk/write.rb +43 -28
- data/lib/wavefront-sdk/writers/api.rb +2 -0
- data/lib/wavefront-sdk/writers/core.rb +21 -4
- data/lib/wavefront-sdk/writers/http.rb +9 -2
- data/lib/wavefront-sdk/writers/socket.rb +11 -9
- data/lib/wavefront-sdk/writers/summary.rb +2 -0
- data/lib/wavefront-sdk/writers/unix.rb +10 -7
- data/lib/wavefront_sdk.rb +3 -1
- data/spec/.rubocop.yml +10 -14
- data/spec/constants.rb +10 -8
- data/spec/spec_helper.rb +2 -0
- data/spec/support/bad_mocket.rb +2 -0
- data/spec/support/hash.rb +2 -0
- data/spec/support/minitest_assertions.rb +2 -0
- data/spec/support/mocket.rb +2 -0
- data/spec/test_mixins/acl.rb +2 -0
- data/spec/test_mixins/general.rb +2 -0
- data/spec/test_mixins/tag.rb +2 -0
- data/spec/test_mixins/update_keys.rb +2 -0
- data/spec/wavefront-sdk/alert_spec.rb +10 -9
- data/spec/wavefront-sdk/api_mixins/user_mixins_spec.rb +1 -0
- data/spec/wavefront-sdk/apitoken_spec.rb +1 -0
- data/spec/wavefront-sdk/cloudintegration_spec.rb +2 -1
- data/spec/wavefront-sdk/core/api_caller_spec.rb +1 -0
- data/spec/wavefront-sdk/core/api_spec.rb +1 -0
- data/spec/wavefront-sdk/core/logger_spec.rb +1 -0
- data/spec/wavefront-sdk/core/response_spec.rb +4 -3
- data/spec/wavefront-sdk/credentials_spec.rb +1 -0
- data/spec/wavefront-sdk/dashboard_spec.rb +1 -0
- data/spec/wavefront-sdk/derivedmetric_spec.rb +1 -0
- data/spec/wavefront-sdk/distribution_spec.rb +6 -5
- data/spec/wavefront-sdk/event_spec.rb +8 -7
- data/spec/wavefront-sdk/externallink_spec.rb +5 -4
- data/spec/wavefront-sdk/integration_spec.rb +1 -0
- data/spec/wavefront-sdk/maintenancewindow_spec.rb +6 -5
- data/spec/wavefront-sdk/message_spec.rb +2 -1
- data/spec/wavefront-sdk/metric_helper_spec.rb +10 -9
- data/spec/wavefront-sdk/metric_spec.rb +1 -0
- data/spec/wavefront-sdk/notificant_spec.rb +1 -0
- data/spec/wavefront-sdk/paginator/base_spec.rb +1 -0
- data/spec/wavefront-sdk/paginator/post_spec.rb +1 -0
- data/spec/wavefront-sdk/proxy_spec.rb +1 -0
- data/spec/wavefront-sdk/query_spec.rb +1 -0
- data/spec/wavefront-sdk/report_spec.rb +1 -0
- data/spec/wavefront-sdk/resources/dummy_points.rb +10 -8
- data/spec/wavefront-sdk/savedsearch_spec.rb +1 -0
- data/spec/wavefront-sdk/search_spec.rb +5 -4
- data/spec/wavefront-sdk/settings_spec.rb +1 -0
- data/spec/wavefront-sdk/source_spec.rb +3 -2
- data/spec/wavefront-sdk/stdlib/array_spec.rb +1 -0
- data/spec/wavefront-sdk/stdlib/hash_spec.rb +1 -0
- data/spec/wavefront-sdk/stdlib/string_spec.rb +1 -0
- data/spec/wavefront-sdk/support/mixins_spec.rb +1 -0
- data/spec/wavefront-sdk/support/parse_time_spec.rb +1 -2
- data/spec/wavefront-sdk/user_spec.rb +1 -0
- data/spec/wavefront-sdk/usergroup_spec.rb +2 -1
- data/spec/wavefront-sdk/validators_spec.rb +1 -2
- data/spec/wavefront-sdk/webhook_spec.rb +7 -6
- data/spec/wavefront-sdk/write_spec.rb +50 -30
- data/spec/wavefront-sdk/writers/api_spec.rb +1 -0
- data/spec/wavefront-sdk/writers/core_spec.rb +1 -0
- data/spec/wavefront-sdk/writers/http_spec.rb +2 -1
- data/spec/wavefront-sdk/writers/socket_spec.rb +1 -0
- data/spec/wavefront-sdk/writers/summary_spec.rb +1 -0
- data/wavefront-sdk.gemspec +4 -2
- metadata +6 -6
@@ -1,20 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Constants used in the write tests
|
2
4
|
#
|
3
5
|
TAGS = { gt1: 'gv1', gt2: 'gv2' }.freeze
|
4
6
|
|
5
|
-
POINT = { path:
|
6
|
-
value:
|
7
|
-
ts:
|
7
|
+
POINT = { path: 'test.metric',
|
8
|
+
value: 123_456,
|
9
|
+
ts: 1_469_987_572,
|
8
10
|
source: 'testhost',
|
9
|
-
tags:
|
11
|
+
tags: { t1: 'v1', t2: 'v2' } }.freeze
|
10
12
|
|
11
13
|
POINT_L = 'test.metric 123456 1469987572 source=testhost t1="v1" ' \
|
12
|
-
't2="v2"'
|
14
|
+
't2="v2"'
|
13
15
|
|
14
16
|
POINT_A = [POINT,
|
15
17
|
POINT.dup.update(ts: 1_469_987_588, value: 54_321)].freeze
|
16
18
|
|
17
|
-
POINTS = [POINT.dup, { path:
|
18
|
-
value:
|
19
|
-
ts:
|
19
|
+
POINTS = [POINT.dup, { path: 'test.other_metric',
|
20
|
+
value: 89,
|
21
|
+
ts: 1_469_987_572,
|
20
22
|
source: 'otherhost' }].freeze
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative '../spec_helper'
|
4
5
|
|
@@ -47,7 +48,7 @@ class WavefrontSearchTest < WavefrontTestBase
|
|
47
48
|
|
48
49
|
assert_equal({ limit: 10,
|
49
50
|
offset: 0,
|
50
|
-
query:
|
51
|
+
query: [
|
51
52
|
{ key: 'k1', value: 'v1', matchingMethod: 'EXACT' },
|
52
53
|
{ key: 'k2', value: 'v2', matchingMethod: 'CONTAINS' }
|
53
54
|
],
|
@@ -72,10 +73,10 @@ class WavefrontSearchTest < WavefrontTestBase
|
|
72
73
|
def payload
|
73
74
|
{ limit: 10,
|
74
75
|
offset: 0,
|
75
|
-
query: [{ key:
|
76
|
-
value:
|
76
|
+
query: [{ key: 'name',
|
77
|
+
value: 'Wavefront',
|
77
78
|
matchingMethod: 'CONTAINS' }],
|
78
|
-
sort: { field:
|
79
|
+
sort: { field: 'string',
|
79
80
|
ascending: true } }
|
80
81
|
end
|
81
82
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative '../spec_helper'
|
4
5
|
require_relative '../test_mixins/general'
|
@@ -41,8 +42,8 @@ class WavefrontSourceTest < WavefrontTestBase
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def payload
|
44
|
-
{ sourceName:
|
45
|
-
tags:
|
45
|
+
{ sourceName: 'source.name',
|
46
|
+
tags: { sourceTag1: true },
|
46
47
|
description: 'Source Description' }
|
47
48
|
end
|
48
49
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative '../../spec_helper'
|
4
5
|
require_relative '../../../lib/wavefront-sdk/support/parse_time'
|
@@ -8,7 +9,6 @@ TSM = 1_517_151_869_523
|
|
8
9
|
|
9
10
|
# Test parse_time class
|
10
11
|
#
|
11
|
-
# rubocop:disable Style/DateTime
|
12
12
|
class WavefrontParseTimeTest < MiniTest::Test
|
13
13
|
attr_reader :pts, :ptm
|
14
14
|
|
@@ -64,4 +64,3 @@ class WavefrontParseTimeTest < MiniTest::Test
|
|
64
64
|
assert_kind_of(Numeric, ptm.parse!)
|
65
65
|
end
|
66
66
|
end
|
67
|
-
# rubocop:enable Style/DateTime
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative '../spec_helper'
|
4
5
|
require_relative '../test_mixins/general'
|
@@ -80,7 +81,7 @@ class WavefrontUserGroupTest < WavefrontTestBase
|
|
80
81
|
end
|
81
82
|
|
82
83
|
def payload
|
83
|
-
{ name:
|
84
|
+
{ name: 'test group',
|
84
85
|
permissions: %w[alerts_management dashboard_management
|
85
86
|
events_management] }
|
86
87
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'date'
|
4
5
|
require_relative '../spec_helper'
|
@@ -52,14 +53,12 @@ class WavefrontValidatorsTest < MiniTest::Test
|
|
52
53
|
good_and_bad('wf_value?', 'InvalidMetricValue', good, bad)
|
53
54
|
end
|
54
55
|
|
55
|
-
# rubocop:disable Style/DateTime
|
56
56
|
def test_wf_ts?
|
57
57
|
good = [Time.now, Date.today, DateTime.now]
|
58
58
|
bad = ['2017-03-25 23:52:22 +0000', 1_490_485_946,
|
59
59
|
'#<Date: 2017-03-25 ((2457838j,0s,0n),+0s,2299161j)>']
|
60
60
|
good_and_bad('wf_ts?', 'InvalidTimestamp', good, bad)
|
61
61
|
end
|
62
|
-
# rubocop:enable Style/DateTime
|
63
62
|
|
64
63
|
def test_wf_ms_ts?
|
65
64
|
good = [Time.now.to_i * 1000]
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative '../spec_helper'
|
4
5
|
require_relative '../test_mixins/general'
|
@@ -27,12 +28,12 @@ class WavefrontWebhookTest < WavefrontTestBase
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def payload
|
30
|
-
{ description:
|
31
|
-
template:
|
32
|
-
title:
|
33
|
-
triggers:
|
34
|
-
recipient:
|
31
|
+
{ description: 'WebHook Description',
|
32
|
+
template: 'POST Body -- Mustache syntax',
|
33
|
+
title: 'WebHook Title',
|
34
|
+
triggers: %w[ALERT_OPENED],
|
35
|
+
recipient: 'http://example.com',
|
35
36
|
customHttpHeaders: {},
|
36
|
-
contentType:
|
37
|
+
contentType: 'text/plain' }
|
37
38
|
end
|
38
39
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative '../spec_helper'
|
4
5
|
require_relative '../support/mocket'
|
@@ -108,56 +109,75 @@ class WavefrontWriteTest < MiniTest::Test
|
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
111
|
-
def
|
112
|
-
|
113
|
-
assert_equal(['test.metric', 123_456, 1_469_987_572, 'testhost',
|
114
|
-
't1="v1" t2="v2"', nil], wf.point_array(p1))
|
112
|
+
def test_point_hash_all_values
|
113
|
+
point = POINT.dup
|
115
114
|
|
116
|
-
|
117
|
-
|
115
|
+
assert_equal({ path: 'test.metric',
|
116
|
+
value: 123_456,
|
117
|
+
ts: 1_469_987_572,
|
118
|
+
source: 'testhost',
|
119
|
+
tags: 't1="v1" t2="v2"',
|
120
|
+
opttags: nil }, wf.point_hash(point))
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_point_hash_missing_timestamp
|
124
|
+
point = POINT.dup.tap { |p| p.delete(:ts) }
|
118
125
|
|
119
|
-
|
120
|
-
|
126
|
+
assert_equal({ path: 'test.metric',
|
127
|
+
value: 123_456,
|
128
|
+
ts: nil,
|
129
|
+
source: 'testhost',
|
130
|
+
tags: 't1="v1" t2="v2"',
|
131
|
+
opttags: nil }, wf.point_hash(point))
|
132
|
+
end
|
121
133
|
|
122
|
-
|
123
|
-
|
124
|
-
't1="v1" t2="v2"', nil], wf.point_array(p4))
|
134
|
+
def test_point_hash_missing_tags
|
135
|
+
point = POINT.dup.tap { |p| p.delete(:tags) }
|
125
136
|
|
126
|
-
|
127
|
-
|
128
|
-
|
137
|
+
assert_equal({ path: 'test.metric',
|
138
|
+
value: 123_456,
|
139
|
+
ts: 1_469_987_572,
|
140
|
+
source: 'testhost',
|
141
|
+
tags: nil,
|
142
|
+
opttags: nil }, wf.point_hash(point))
|
129
143
|
end
|
130
144
|
|
131
145
|
def test_hash_to_wf
|
132
146
|
assert_equal(wf.hash_to_wf(POINT),
|
133
147
|
'test.metric 123456 1469987572 ' \
|
134
148
|
'source=testhost t1="v1" t2="v2"')
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_hash_to_wf_tags_via_options
|
135
152
|
assert_equal(wf_tags.hash_to_wf(POINT),
|
136
153
|
'test.metric 123456 1469987572 ' \
|
137
154
|
'source=testhost t1="v1" t2="v2" ' \
|
138
155
|
'gt1="gv1" gt2="gv2"')
|
156
|
+
end
|
139
157
|
|
140
|
-
|
141
|
-
|
142
|
-
assert_equal(wf.hash_to_wf(
|
158
|
+
def test_hash_to_wf_missing_timestamp
|
159
|
+
point = POINT.dup.tap { |p| p.delete(:ts) }
|
160
|
+
assert_equal(wf.hash_to_wf(point),
|
143
161
|
'test.metric 123456 source=testhost t1="v1" t2="v2"')
|
162
|
+
end
|
144
163
|
|
145
|
-
|
146
|
-
|
147
|
-
assert_equal(wf.hash_to_wf(
|
164
|
+
def test_hash_to_wf_missing_tags
|
165
|
+
point = POINT.dup.tap { |p| p.delete(:tags) }
|
166
|
+
assert_equal(wf.hash_to_wf(point),
|
148
167
|
'test.metric 123456 1469987572 source=testhost')
|
168
|
+
end
|
149
169
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
end
|
170
|
+
def test_hash_to_wf_missing_value
|
171
|
+
point = POINT.dup.tap { |p| p.delete(:value) }
|
172
|
+
assert_raises(Wavefront::Exception::InvalidMetricValue) do
|
173
|
+
wf.hash_to_wf(point)
|
174
|
+
end
|
175
|
+
end
|
157
176
|
|
158
|
-
|
159
|
-
|
160
|
-
|
177
|
+
def test_hash_to_wf_missing_path
|
178
|
+
point = POINT.dup.tap { |p| p.delete(:path) }
|
179
|
+
assert_raises(Wavefront::Exception::InvalidMetricName) do
|
180
|
+
wf.hash_to_wf(point)
|
161
181
|
end
|
162
182
|
end
|
163
183
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative '../../spec_helper'
|
4
5
|
require_relative '../resources/dummy_points'
|
5
6
|
require_relative '../../../lib/wavefront-sdk/write'
|
6
7
|
|
7
|
-
BODY = 'test.metric 123456 1469987572 source=testhost t1="v1" t2="v2"'
|
8
|
+
BODY = 'test.metric 123456 1469987572 source=testhost t1="v1" t2="v2"'
|
8
9
|
|
9
10
|
# Test HTTP transport
|
10
11
|
#
|
data/wavefront-sdk.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
require 'date'
|
3
5
|
require_relative 'lib/wavefront-sdk/defs/version'
|
@@ -27,8 +29,8 @@ Gem::Specification.new do |gem|
|
|
27
29
|
|
28
30
|
gem.add_development_dependency 'minitest', '~> 5.11'
|
29
31
|
gem.add_development_dependency 'rake', '~> 12.3'
|
30
|
-
gem.add_development_dependency 'rubocop', '~> 0.
|
31
|
-
gem.add_development_dependency 'simplecov', '~> 0.16
|
32
|
+
gem.add_development_dependency 'rubocop', '~> 0.74'
|
33
|
+
gem.add_development_dependency 'simplecov', '~> 0.16'
|
32
34
|
gem.add_development_dependency 'spy', '~> 1.0.0'
|
33
35
|
gem.add_development_dependency 'webmock', '~> 3.7'
|
34
36
|
gem.add_development_dependency 'yard', '~> 0.9'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wavefront-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Fisher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -100,28 +100,28 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: '0.74'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: '0.74'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.16
|
117
|
+
version: '0.16'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.16
|
124
|
+
version: '0.16'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: spy
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|