vault-tools 0.5.22 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30a308b70cb2b0dd36a4adbfa44579504e0e3eda
4
- data.tar.gz: 25851c62a3c1cdede8a40045c7ad413227be03d7
3
+ metadata.gz: 3659a73e16232326982244fac1ce9ed09b5ad45f
4
+ data.tar.gz: 5ce1c3c552061e26ff1e945d8f82dbfa626fb2b3
5
5
  SHA512:
6
- metadata.gz: df817efcb1d0e58585de50f92d3db33e378d5955b2cd2e5c07911cee2524395dd3b48db8c289ab91e809625daa12a8753b7f8fa43fc6ef78314a4ea06cab20ab
7
- data.tar.gz: bb7171a789a86faec92e237759342855921220f651f309e9208bedc2a2092b84a8d3b5006e5aff64df5128e4d110e8affdd5f324d8a02452778883908630482b
6
+ metadata.gz: 89d887c7303d0246b93ac07a591f9db3deb4f47101702b8c528fb16891e6ea40b776dfc48e23d5008b1272b980403858c2fac0be00ce494879188a03ae196993
7
+ data.tar.gz: 5b1fd861313db8223070531f7290da7e2e2474ca0426000135ff15578f271e96e2587a8caa2e9182035257017f8942792ee00f20e656e31040450189917e9d40
data/.gitignore CHANGED
@@ -18,3 +18,4 @@ tmp
18
18
  test.profile*
19
19
  test/.test.profile*
20
20
  vendor
21
+ .tool-versions
data/.travis.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.2.0
5
- - 2.0.0
6
- - 1.9.3
7
- - jruby-19mode # JRuby in 1.9 mode
4
+ - 2.5.0
5
+ - 2.4.0
6
+ - 2.3.0
data/Gemfile.lock CHANGED
@@ -1,76 +1,80 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vault-tools (0.5.22)
4
+ vault-tools (0.6.0)
5
5
  aws-sdk (~> 1.0)
6
6
  coderay
7
7
  excon
8
8
  fernet (= 2.0.rc2)
9
9
  heroku-api
10
- pry
11
10
  rack (~> 1.6.4)
12
11
  rack-ssl-enforcer
13
- rdoc
14
12
  rollbar (~> 2.7.1)
15
13
  scrolls
16
14
  sinatra (~> 1.4.4)
17
15
  uuidtools
18
- yard
16
+ zipkin-tracer (~> 0.27)
19
17
 
20
18
  GEM
21
19
  remote: https://rubygems.org/
22
20
  specs:
23
21
  ansi (1.5.0)
24
- aws-sdk (1.66.0)
25
- aws-sdk-v1 (= 1.66.0)
26
- aws-sdk-v1 (1.66.0)
22
+ aws-sdk (1.67.0)
23
+ aws-sdk-v1 (= 1.67.0)
24
+ aws-sdk-v1 (1.67.0)
27
25
  json (~> 1.4)
28
- nokogiri (>= 1.4.4)
29
- coderay (1.1.1)
26
+ nokogiri (~> 1)
27
+ coderay (1.1.2)
28
+ concurrent-ruby (1.0.5)
30
29
  dotenv (2.0.0)
31
- excon (0.54.0)
30
+ excon (0.60.0)
31
+ faraday (0.14.0)
32
+ multipart-post (>= 1.2, < 3)
32
33
  fernet (2.0.rc2)
33
34
  valcro (= 0.1)
35
+ finagle-thrift (1.4.2)
36
+ thrift (~> 0.9.3)
34
37
  guard-compat (1.2.1)
35
38
  guard-minitest (2.4.4)
36
39
  guard-compat (~> 1.2)
37
40
  minitest (>= 3.0)
38
- heroku-api (0.4.1)
41
+ heroku-api (0.4.3)
39
42
  excon (~> 0.45)
40
43
  multi_json (~> 1.8)
41
- json (1.8.3)
44
+ json (1.8.6)
42
45
  logfmt (0.0.7)
43
- method_source (0.8.2)
46
+ method_source (0.9.0)
44
47
  mini_portile (0.6.2)
45
48
  minitest (4.7.5)
46
- multi_json (1.12.1)
49
+ multi_json (1.13.1)
50
+ multipart-post (2.0.0)
47
51
  nokogiri (1.6.6.2)
48
52
  mini_portile (~> 0.6.0)
49
- pry (0.10.4)
53
+ pry (0.11.3)
50
54
  coderay (~> 1.1.0)
51
- method_source (~> 0.8.1)
52
- slop (~> 3.4)
55
+ method_source (~> 0.9.0)
53
56
  rack (1.6.4)
54
- rack-protection (1.5.3)
57
+ rack-protection (1.5.4)
55
58
  rack
56
59
  rack-ssl-enforcer (0.2.9)
57
60
  rack-test (0.6.3)
58
61
  rack (>= 1.0)
59
62
  rake (10.4.2)
60
- rdoc (4.2.2)
61
- json (~> 1.4)
63
+ rdoc (6.0.1)
62
64
  rollbar (2.7.1)
63
65
  multi_json
64
66
  rr (1.1.2)
65
67
  scrolls (0.3.8)
66
68
  shotgun (0.9.1)
67
69
  rack (>= 1.0)
68
- sinatra (1.4.7)
70
+ sinatra (1.4.8)
69
71
  rack (~> 1.5)
70
72
  rack-protection (~> 1.4)
71
73
  tilt (>= 1.3, < 3)
72
- slop (3.6.0)
73
- tilt (2.0.5)
74
+ sucker_punch (2.0.4)
75
+ concurrent-ruby (~> 1.0.0)
76
+ thrift (0.9.3.0)
77
+ tilt (2.0.8)
74
78
  turn (0.9.7)
75
79
  ansi
76
80
  minitest (~> 4)
@@ -88,6 +92,11 @@ GEM
88
92
  yard (0.8.7.6)
89
93
  yard-sinatra (1.0.0)
90
94
  yard (~> 0.7)
95
+ zipkin-tracer (0.27.2.1)
96
+ faraday (~> 0.8)
97
+ finagle-thrift (~> 1.4.2)
98
+ rack (>= 1.0)
99
+ sucker_punch (~> 2.0)
91
100
 
92
101
  PLATFORMS
93
102
  ruby
@@ -95,11 +104,14 @@ PLATFORMS
95
104
  DEPENDENCIES
96
105
  dotenv
97
106
  guard-minitest
107
+ pry
98
108
  rake
109
+ rdoc
99
110
  shotgun
100
111
  vault-test-tools
101
112
  vault-tools!
113
+ yard
102
114
  yard-sinatra
103
115
 
104
116
  BUNDLED WITH
105
- 1.13.6
117
+ 1.16.1
data/README.md CHANGED
@@ -26,6 +26,8 @@ calling `Vault.setup` will:
26
26
  - if the `CONFIG_APP` environment variable is defined and this is
27
27
  the production environment, it will attempt to use the Heroku API
28
28
  to load the config vars from another app into `Vault::Config`
29
+ - enable distributed tracing via Zipkin, if the [required config
30
+ vars](#configs-for-tracing) are set
29
31
 
30
32
 
31
33
  ### `Vault::Config`
@@ -91,15 +93,15 @@ Generate the API documentation:
91
93
 
92
94
  vendor/bin/d
93
95
 
96
+ ## Configs for tracing
94
97
 
95
-
96
- ## Contributing
97
-
98
- 1. Fork it
99
- 2. Create your feature branch (`git checkout -b my-new-feature`)
100
- 3. Commit your changes (`git commit -am 'Add some feature'`)
101
- 4. Push to the branch (`git push origin my-new-feature`)
102
- 5. Create new Pull Request
98
+ The following are config vars to be set in the consumer app for tracing with
99
+ Zipkin:
100
+ * `APP_NAME` (required) what the trace will show up as in the Zipkin interface.
101
+ * `ZIPKIN_ENABLED` (required) must be set to `true` to start tracing.
102
+ * `ZIPKIN_API_HOST` (required) where to post traces to. URL must contain the
103
+ basic auth creds from the Tools team.
104
+ * `ZIPKIN_SAMPLE_RATE` defaults to `0.1`.
103
105
 
104
106
  ## Releasing
105
107
 
data/lib/vault-tools.rb CHANGED
@@ -74,6 +74,7 @@ module Vault
74
74
  self.hack_time_class
75
75
  self.override_global_config
76
76
  self.load_shared_config
77
+ Tracing.configure
77
78
  end
78
79
  end
79
80
 
@@ -91,3 +92,4 @@ require 'vault-tools/time'
91
92
  require 'vault-tools/s3'
92
93
  require 'vault-tools/statement_store'
93
94
  require 'vault-tools/rollbar_helper'
95
+ require 'vault-tools/tracing'
@@ -2,7 +2,7 @@ require 'uuidtools'
2
2
 
3
3
  module Vault
4
4
  module App
5
- ID_CAPTURE = /^app(\d+)\@[\w\.]+com$/
5
+ ID_CAPTURE = /\Aapp(\d+)\@[\w\.]+com\z/
6
6
  # Convert a core app ID into a Heroku app ID.
7
7
  #
8
8
  # @param app_id [Fixnum] A core app ID.
@@ -0,0 +1,40 @@
1
+ module Vault
2
+ module Tracing
3
+ ZIPKIN_API_HOST_STAGING = 'https://zipkin-staging.heroku.tools'.freeze
4
+
5
+ # Injects the zipkin middleware into the Web class.
6
+ #
7
+ # @example
8
+ # Vault::Tracing.configure
9
+ #
10
+ # @return nil
11
+ def self.configure
12
+ return unless Vault::Tracing.enabled?
13
+
14
+ Vault::Web.instance_eval { require 'zipkin-tracer' }
15
+ Vault::Web.use ZipkinTracer::RackHandler, config
16
+ end
17
+
18
+ # Configuration options for the Zipkin RackHandler.
19
+ #
20
+ # @return [Hash] config options for Zipkin tracer
21
+ def self.config
22
+ {
23
+ service_name: Config.app_name,
24
+ service_port: 443,
25
+ json_api_host: Config[:zipkin_api_host],
26
+ sample_rate: (Config[:zipkin_sample_rate] || 0.1).to_f,
27
+ sampled_as_boolean: false
28
+ }
29
+ end
30
+
31
+ # A helper to guard against injecting Zipkin when not desired.
32
+ #
33
+ # @return [true] if so
34
+ def self.enabled?
35
+ Config.app_name &&
36
+ Config[:zipkin_enabled] == 'true' &&
37
+ Config[:zipkin_api_host]
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  module Vault
2
2
  module Tools
3
- VERSION = '0.5.22'
3
+ VERSION = '0.6.0'
4
4
  end
5
5
  end
@@ -0,0 +1,63 @@
1
+ require 'helper'
2
+
3
+ class TracingTest < Vault::TestCase
4
+ # Anonymous Web Frontend
5
+ def app
6
+ @app ||= Class.new(Vault::Web)
7
+ end
8
+
9
+ # Middleware is attached at load time, so we have to delete the Vault::Web
10
+ # class and reload it to simulate being loaded with different environment
11
+ # variables.
12
+ def reload_web!
13
+ # remove the constant to force a clean reload
14
+ Vault.send(:remove_const, 'Web')
15
+ load 'lib/vault-tools/web.rb'
16
+ end
17
+
18
+ # Always reload the web class to eliminate test leakage
19
+ def setup
20
+ super
21
+ reload_web!
22
+ enable
23
+ end
24
+
25
+ def teardown
26
+ super
27
+ @app = nil
28
+ end
29
+
30
+ def enable
31
+ set_env('APP_NAME', 'test_app')
32
+ set_env('ZIPKIN_ENABLED', 'true')
33
+ set_env('ZIPKIN_API_HOST', 'http://localhost')
34
+ end
35
+
36
+ def disable
37
+ set_env('ZIPKIN_ENABLED', nil)
38
+ end
39
+
40
+ def test_configure_enabled
41
+ Vault::Tracing.configure
42
+ middleware_constants = app.middleware.map(&:first)
43
+ assert middleware_constants.include?(ZipkinTracer::RackHandler),
44
+ "expected ZipkinTracer::RackHandler to be in the middleware stack, got #{middleware_constants}"
45
+ end
46
+
47
+ def test_configure_not_enabled
48
+ disable
49
+ refute Vault::Tracing.configure,
50
+ 'Vault::Tracing.configure should return nil when not enabled'
51
+ end
52
+
53
+ def test_enabled_true
54
+ assert Vault::Tracing.enabled?,
55
+ 'Vault::Tracing.enabled? should return true when enabled'
56
+ end
57
+
58
+ def test_enabled_false
59
+ disable
60
+ refute Vault::Tracing.enabled?,
61
+ 'Vault::Tracing.enabled? should return false when not enabled'
62
+ end
63
+ end
data/vault-tools.gemspec CHANGED
@@ -24,13 +24,14 @@ Gem::Specification.new do |gem|
24
24
  gem.add_dependency 'heroku-api'
25
25
  gem.add_dependency 'fernet', '2.0.rc2'
26
26
  gem.add_dependency 'rollbar', '~> 2.7.1'
27
- gem.add_dependency 'rdoc'
28
- gem.add_dependency 'yard'
29
27
  gem.add_dependency 'aws-sdk', '~> 1.0'
30
28
  gem.add_dependency 'excon'
31
29
  gem.add_dependency 'rack', '~> 1.6.4'
32
30
  gem.add_dependency 'coderay'
33
- gem.add_dependency 'pry'
31
+ gem.add_dependency 'zipkin-tracer', '~> 0.27'
34
32
 
35
33
  gem.add_development_dependency 'dotenv'
34
+ gem.add_development_dependency 'pry'
35
+ gem.add_development_dependency 'rdoc'
36
+ gem.add_development_dependency 'yard'
36
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vault-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.22
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Continanza
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-05 00:00:00.000000000 Z
12
+ date: 2018-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: scrolls
@@ -110,21 +110,21 @@ dependencies:
110
110
  - !ruby/object:Gem::Version
111
111
  version: 2.7.1
112
112
  - !ruby/object:Gem::Dependency
113
- name: rdoc
113
+ name: aws-sdk
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: '0'
118
+ version: '1.0'
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ">="
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '0'
125
+ version: '1.0'
126
126
  - !ruby/object:Gem::Dependency
127
- name: yard
127
+ name: excon
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
@@ -138,21 +138,21 @@ dependencies:
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  - !ruby/object:Gem::Dependency
141
- name: aws-sdk
141
+ name: rack
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - "~>"
145
145
  - !ruby/object:Gem::Version
146
- version: '1.0'
146
+ version: 1.6.4
147
147
  type: :runtime
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - "~>"
152
152
  - !ruby/object:Gem::Version
153
- version: '1.0'
153
+ version: 1.6.4
154
154
  - !ruby/object:Gem::Dependency
155
- name: excon
155
+ name: coderay
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - ">="
@@ -166,27 +166,27 @@ dependencies:
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  - !ruby/object:Gem::Dependency
169
- name: rack
169
+ name: zipkin-tracer
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - "~>"
173
173
  - !ruby/object:Gem::Version
174
- version: 1.6.4
174
+ version: '0.27'
175
175
  type: :runtime
176
176
  prerelease: false
177
177
  version_requirements: !ruby/object:Gem::Requirement
178
178
  requirements:
179
179
  - - "~>"
180
180
  - !ruby/object:Gem::Version
181
- version: 1.6.4
181
+ version: '0.27'
182
182
  - !ruby/object:Gem::Dependency
183
- name: coderay
183
+ name: dotenv
184
184
  requirement: !ruby/object:Gem::Requirement
185
185
  requirements:
186
186
  - - ">="
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0'
189
- type: :runtime
189
+ type: :development
190
190
  prerelease: false
191
191
  version_requirements: !ruby/object:Gem::Requirement
192
192
  requirements:
@@ -200,7 +200,7 @@ dependencies:
200
200
  - - ">="
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
- type: :runtime
203
+ type: :development
204
204
  prerelease: false
205
205
  version_requirements: !ruby/object:Gem::Requirement
206
206
  requirements:
@@ -208,7 +208,21 @@ dependencies:
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  - !ruby/object:Gem::Dependency
211
- name: dotenv
211
+ name: rdoc
212
+ requirement: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: '0'
217
+ type: :development
218
+ prerelease: false
219
+ version_requirements: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - ">="
222
+ - !ruby/object:Gem::Version
223
+ version: '0'
224
+ - !ruby/object:Gem::Dependency
225
+ name: yard
212
226
  requirement: !ruby/object:Gem::Requirement
213
227
  requirements:
214
228
  - - ">="
@@ -258,6 +272,7 @@ files:
258
272
  - lib/vault-tools/tasks.rb
259
273
  - lib/vault-tools/text_processor.rb
260
274
  - lib/vault-tools/time.rb
275
+ - lib/vault-tools/tracing.rb
261
276
  - lib/vault-tools/usage_db_tasks.rb
262
277
  - lib/vault-tools/user.rb
263
278
  - lib/vault-tools/vault_db_tasks.rb
@@ -275,6 +290,7 @@ files:
275
290
  - test/statement_store_test.rb
276
291
  - test/text_processor_test.rb
277
292
  - test/time_test.rb
293
+ - test/tracing_test.rb
278
294
  - test/user_test.rb
279
295
  - test/web_test.rb
280
296
  - vault-tools.gemspec
@@ -297,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
297
313
  version: '0'
298
314
  requirements: []
299
315
  rubyforge_project:
300
- rubygems_version: 2.5.1
316
+ rubygems_version: 2.6.13
301
317
  signing_key:
302
318
  specification_version: 4
303
319
  summary: Test classes, base web classes, and helpers - oh my!