vault-tools 0.7.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -155,6 +155,7 @@ class WebTest < Vault::TestCase
155
155
  head '/'
156
156
  assert_equal '1', logged_data['count#test-app.http.200']
157
157
  assert_equal '1', logged_data['count#test-app.http.2xx']
158
+ assert_equal '/', logged_data['request_path']
158
159
  assert_equal(200, last_response.status)
159
160
  end
160
161
 
@@ -7,28 +7,29 @@ require 'vault-tools/version'
7
7
  Gem::Specification.new do |gem|
8
8
  gem.name = "vault-tools"
9
9
  gem.version = Vault::Tools::VERSION
10
- gem.authors = ["Chris Continanza", "Jamu Kakar"]
11
- gem.email = ["christopher.continanza@gmail.com", "csquared@heroku.com","jkakar@heroku.com","jkakar@kakar.ca"]
10
+ gem.authors = ["Chris Continanza", "Jamu Kakar", "Kenny Parnell"]
11
+ gem.email = ["csquared@heroku.com", "christopher.continanza@gmail.com",
12
+ "jkakar@heroku.com","jkakar@kakar.ca",
13
+ "kennyp@heroku.com", "k.parnell@gmail.com"]
12
14
  gem.description = "Basic tools for Heroku Vault's Ruby projects"
13
15
  gem.summary = "Test classes, base web classes, and helpers - oh my!"
14
16
  gem.homepage = ""
17
+ gem.required_ruby_version = '>= 2.5.3'
15
18
 
16
19
  gem.files = `git ls-files`.split($/)
17
20
  gem.test_files = gem.files.grep('^(test|spec|features)/')
18
21
  gem.require_paths = ["lib"]
19
22
 
20
23
  gem.add_dependency 'scrolls', '~> 0.9'
21
- gem.add_dependency 'sinatra', '~> 1.4.4'
24
+ gem.add_dependency 'sinatra', '~> 2.0.4'
22
25
  gem.add_dependency 'uuidtools'
23
26
  gem.add_dependency 'rack-ssl-enforcer'
24
- gem.add_dependency 'heroku-api'
25
- gem.add_dependency 'fernet', '2.0.rc2'
26
- gem.add_dependency 'rollbar', '~> 2.7.1'
27
- gem.add_dependency 'aws-sdk', '~> 1.0'
27
+ gem.add_dependency 'fernet', '2.0'
28
+ gem.add_dependency 'rollbar', '~> 2.18.2'
29
+ gem.add_dependency 'aws-sdk-s3', '~> 1.0'
28
30
  gem.add_dependency 'excon'
29
- gem.add_dependency 'rack', '~> 1.6.4'
31
+ gem.add_dependency 'rack', '~> 2.0'
30
32
  gem.add_dependency 'coderay'
31
- gem.add_dependency 'zipkin-tracer', '~> 0.27'
32
33
 
33
34
  gem.add_development_dependency 'dotenv'
34
35
  gem.add_development_dependency 'pry'
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vault-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Continanza
8
8
  - Jamu Kakar
9
+ - Kenny Parnell
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2018-06-04 00:00:00.000000000 Z
13
+ date: 2020-06-23 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: scrolls
@@ -31,14 +32,14 @@ dependencies:
31
32
  requirements:
32
33
  - - "~>"
33
34
  - !ruby/object:Gem::Version
34
- version: 1.4.4
35
+ version: 2.0.4
35
36
  type: :runtime
36
37
  prerelease: false
37
38
  version_requirements: !ruby/object:Gem::Requirement
38
39
  requirements:
39
40
  - - "~>"
40
41
  - !ruby/object:Gem::Version
41
- version: 1.4.4
42
+ version: 2.0.4
42
43
  - !ruby/object:Gem::Dependency
43
44
  name: uuidtools
44
45
  requirement: !ruby/object:Gem::Requirement
@@ -67,50 +68,36 @@ dependencies:
67
68
  - - ">="
68
69
  - !ruby/object:Gem::Version
69
70
  version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: heroku-api
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :runtime
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
71
  - !ruby/object:Gem::Dependency
85
72
  name: fernet
86
73
  requirement: !ruby/object:Gem::Requirement
87
74
  requirements:
88
75
  - - '='
89
76
  - !ruby/object:Gem::Version
90
- version: 2.0.rc2
77
+ version: '2.0'
91
78
  type: :runtime
92
79
  prerelease: false
93
80
  version_requirements: !ruby/object:Gem::Requirement
94
81
  requirements:
95
82
  - - '='
96
83
  - !ruby/object:Gem::Version
97
- version: 2.0.rc2
84
+ version: '2.0'
98
85
  - !ruby/object:Gem::Dependency
99
86
  name: rollbar
100
87
  requirement: !ruby/object:Gem::Requirement
101
88
  requirements:
102
89
  - - "~>"
103
90
  - !ruby/object:Gem::Version
104
- version: 2.7.1
91
+ version: 2.18.2
105
92
  type: :runtime
106
93
  prerelease: false
107
94
  version_requirements: !ruby/object:Gem::Requirement
108
95
  requirements:
109
96
  - - "~>"
110
97
  - !ruby/object:Gem::Version
111
- version: 2.7.1
98
+ version: 2.18.2
112
99
  - !ruby/object:Gem::Dependency
113
- name: aws-sdk
100
+ name: aws-sdk-s3
114
101
  requirement: !ruby/object:Gem::Requirement
115
102
  requirements:
116
103
  - - "~>"
@@ -143,14 +130,14 @@ dependencies:
143
130
  requirements:
144
131
  - - "~>"
145
132
  - !ruby/object:Gem::Version
146
- version: 1.6.4
133
+ version: '2.0'
147
134
  type: :runtime
148
135
  prerelease: false
149
136
  version_requirements: !ruby/object:Gem::Requirement
150
137
  requirements:
151
138
  - - "~>"
152
139
  - !ruby/object:Gem::Version
153
- version: 1.6.4
140
+ version: '2.0'
154
141
  - !ruby/object:Gem::Dependency
155
142
  name: coderay
156
143
  requirement: !ruby/object:Gem::Requirement
@@ -165,20 +152,6 @@ dependencies:
165
152
  - - ">="
166
153
  - !ruby/object:Gem::Version
167
154
  version: '0'
168
- - !ruby/object:Gem::Dependency
169
- name: zipkin-tracer
170
- requirement: !ruby/object:Gem::Requirement
171
- requirements:
172
- - - "~>"
173
- - !ruby/object:Gem::Version
174
- version: '0.27'
175
- type: :runtime
176
- prerelease: false
177
- version_requirements: !ruby/object:Gem::Requirement
178
- requirements:
179
- - - "~>"
180
- - !ruby/object:Gem::Version
181
- version: '0.27'
182
155
  - !ruby/object:Gem::Dependency
183
156
  name: dotenv
184
157
  requirement: !ruby/object:Gem::Requirement
@@ -237,10 +210,12 @@ dependencies:
237
210
  version: '0'
238
211
  description: Basic tools for Heroku Vault's Ruby projects
239
212
  email:
240
- - christopher.continanza@gmail.com
241
213
  - csquared@heroku.com
214
+ - christopher.continanza@gmail.com
242
215
  - jkakar@heroku.com
243
216
  - jkakar@kakar.ca
217
+ - kennyp@heroku.com
218
+ - k.parnell@gmail.com
244
219
  executables: []
245
220
  extensions: []
246
221
  extra_rdoc_files: []
@@ -272,9 +247,6 @@ files:
272
247
  - lib/vault-tools/tasks.rb
273
248
  - lib/vault-tools/text_processor.rb
274
249
  - lib/vault-tools/time.rb
275
- - lib/vault-tools/tracing.rb
276
- - lib/vault-tools/tracing/sidekiq_client.rb
277
- - lib/vault-tools/tracing/sidekiq_server.rb
278
250
  - lib/vault-tools/usage_db_tasks.rb
279
251
  - lib/vault-tools/user.rb
280
252
  - lib/vault-tools/vault_db_tasks.rb
@@ -292,7 +264,6 @@ files:
292
264
  - test/statement_store_test.rb
293
265
  - test/text_processor_test.rb
294
266
  - test/time_test.rb
295
- - test/tracing_test.rb
296
267
  - test/user_test.rb
297
268
  - test/web_test.rb
298
269
  - vault-tools.gemspec
@@ -307,7 +278,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
307
278
  requirements:
308
279
  - - ">="
309
280
  - !ruby/object:Gem::Version
310
- version: '0'
281
+ version: 2.5.3
311
282
  required_rubygems_version: !ruby/object:Gem::Requirement
312
283
  requirements:
313
284
  - - ">="
@@ -315,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
286
  version: '0'
316
287
  requirements: []
317
288
  rubyforge_project:
318
- rubygems_version: 2.5.2.3
289
+ rubygems_version: 2.7.6.2
319
290
  signing_key:
320
291
  specification_version: 4
321
292
  summary: Test classes, base web classes, and helpers - oh my!
@@ -1,92 +0,0 @@
1
- require 'zipkin-tracer'
2
-
3
- module Vault
4
- module Tracing
5
- ZIPKIN_API_HOST_STAGING = 'https://zipkin-staging.heroku.tools'.freeze
6
-
7
- # Injects the zipkin middleware into the Web class, add Zipkin middleware to
8
- # Excon.
9
- #
10
- # @example
11
- # Vault::Tracing.configure
12
- #
13
- # @return nil
14
- def self.configure
15
- return unless Vault::Tracing.enabled?
16
-
17
- Vault::Web.instance_eval { require 'zipkin-tracer' }
18
- Vault::Web.use ZipkinTracer::RackHandler, config
19
- setup_excon
20
- end
21
-
22
- # Traces a local component. Useful to track down long running implementation
23
- # methods within an app, instead of only tracing external calls.
24
- #
25
- # @param name [String] the name of the span to record in Zipkin.
26
- # @param tracer [Constant] the const that should respond to :local_component_span
27
- # @param options [Hash] the options to create a message with.
28
- #
29
- # @example
30
- # Vault::Tracing.trace_local 'cashier_middleware_x', internal: true do
31
- # # some expensive task
32
- # end
33
- #
34
- # @yield [the_block_passed_in]
35
- def self.trace_local(name, tracer = ZipkinTracer::TraceClient, **options)
36
- return yield unless Vault::Tracing.enabled?
37
-
38
- tracer.local_component_span(name) do |span|
39
- span.name = name
40
- span.record_tag('options', options.to_s) unless options.empty?
41
- yield
42
- end
43
- end
44
-
45
- # Configuration options for the Zipkin RackHandler.
46
- #
47
- # @return [Hash] config options for Zipkin tracer
48
- def self.config
49
- {
50
- service_name: "#{Config.app_name}.herokuapp.com",
51
- service_port: 443,
52
- json_api_host: Config[:zipkin_api_host],
53
- sample_rate: (Config[:zipkin_sample_rate] || 0.1).to_f,
54
- sampled_as_boolean: false
55
- }
56
- end
57
-
58
- # A helper to guard against injecting Zipkin when not desired.
59
- #
60
- # @return [true] if so
61
- def self.enabled?
62
- Config.app_name &&
63
- Config[:zipkin_enabled] == 'true' &&
64
- Config[:zipkin_api_host]
65
- end
66
-
67
- # Adds ZipkinTracer::ExconHandler to Excon's default middlewares if Excon is
68
- # defined
69
- #
70
- # @private
71
- #
72
- # @return nil
73
- def self.setup_excon
74
- if add_to_excon_middlewares?
75
- Excon.defaults[:middlewares].push(ZipkinTracer::ExconHandler)
76
- end
77
- end
78
- private_class_method :setup_excon
79
-
80
- # Checks to see if Excon is defined and if the Zipkin middleware has already
81
- # been inserted.
82
- #
83
- # @private
84
- #
85
- # @return [true] if Excon is defined and the middleware is not already
86
- # inserted
87
- def self.add_to_excon_middlewares?
88
- defined?(Excon) && !Excon.defaults[:middlewares].include?(ZipkinTracer::ExconHandler)
89
- end
90
- private_class_method :add_to_excon_middlewares?
91
- end
92
- end
@@ -1,37 +0,0 @@
1
- module Vault
2
- module Tracing
3
- # Tracing info for sidekiq, adding them as params
4
- # This was lifted straight out of heroku/coal_car
5
- class SidekiqClient
6
- def trace_information(trace_id)
7
- {
8
- "trace_id" => trace_id.trace_id,
9
- "parent_id" => trace_id.parent_id,
10
- "span_id" => trace_id.span_id,
11
- "sampled" => trace_id.sampled,
12
- "flags" => trace_id.flags
13
- }
14
- end
15
-
16
- def call(worker_class, job, _queue, _redis_pool)
17
- trace_id = ::ZipkinTracer::TraceGenerator.new.next_trace_id
18
- ::ZipkinTracer::TraceContainer.with_trace_id(trace_id) do
19
- job["zipkin_trace_information"] = trace_information(trace_id)
20
- if trace_id.sampled?
21
- ::Trace.tracer.with_new_span(trace_id, "sidekiq") do |span|
22
- local_endpoint = Trace.default_endpoint
23
- klass = job["wrapped".freeze] || worker_class
24
- span.record_tag("job_class",
25
- klass,
26
- ::Trace::BinaryAnnotation::Type::STRING,
27
- local_endpoint)
28
- yield
29
- end
30
- else
31
- yield
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,54 +0,0 @@
1
- module Vault
2
- module Tracing
3
- # Tracing info for sidekiq
4
- # This was lifted straight out of heroku/coal_car
5
- class SidekiqServer
6
- def initialize(config = nil)
7
- @config = ZipkinTracer::Config.new(nil, config).freeze
8
- @tracer = ZipkinTracer::TracerFactory.new.tracer(@config)
9
- end
10
-
11
- def call(worker, job, _queue)
12
- result = nil
13
- id = trace_id(job)
14
- klass = job["wrapped".freeze] || worker.class.to_s
15
- ::ZipkinTracer::TraceContainer.with_trace_id(id) do
16
- if id.sampled?
17
- @tracer.with_new_span(id, klass) do |span|
18
- span.record("sidekiq.start")
19
- result = yield
20
- span.record("sidekiq.end")
21
- end
22
- else
23
- yield
24
- end
25
- end
26
- ::Trace.tracer.flush! if ::Trace.tracer.respond_to?(:flush!)
27
- result
28
- end
29
-
30
- private
31
-
32
- def trace_id(job)
33
- info = job["zipkin_trace_information"]
34
- if info
35
- trace_id = info["trace_id"]
36
- span_id = info["span_id"]
37
- parent_span_id = info["parent_id"]
38
- sampled = info["sampled"]
39
- flags = info["flags"].to_i
40
- else
41
- trace_id = span_id = ::Trace.generate_id
42
- parent_span_id = nil
43
- sampled = sample?
44
- flags = ::Trace::Flags::EMPTY
45
- end
46
- ::Trace::TraceId.new(trace_id, parent_span_id, span_id, sampled, flags)
47
- end
48
-
49
- def sample?
50
- rand < @config.sample_rate
51
- end
52
- end
53
- end
54
- end
@@ -1,86 +0,0 @@
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_service_name_gets_herokuapp
41
- assert_equal 'test_app.herokuapp.com', Vault::Tracing.config[:service_name]
42
- end
43
-
44
- def test_configure_enabled
45
- Vault::Tracing.configure
46
- middleware_constants = app.middleware.map(&:first)
47
- assert middleware_constants.include?(ZipkinTracer::RackHandler),
48
- "expected ZipkinTracer::RackHandler to be in the middleware stack, got #{middleware_constants}"
49
- end
50
-
51
- def test_configure_not_enabled
52
- disable
53
- refute Vault::Tracing.configure,
54
- 'Vault::Tracing.configure should return nil when not enabled'
55
- end
56
-
57
- def test_excon
58
- Vault::Tracing.configure
59
- assert Excon.defaults[:middlewares].include?(ZipkinTracer::ExconHandler),
60
- "Vault::Tracing.setup_excon should add ZipkinTracer::ExconHandler to excon's middleware"
61
- end
62
-
63
- def test_enabled_true
64
- assert Vault::Tracing.enabled?,
65
- 'Vault::Tracing.enabled? should return true when enabled'
66
- end
67
-
68
- def test_enabled_false
69
- disable
70
- refute Vault::Tracing.enabled?,
71
- 'Vault::Tracing.enabled? should return false when not enabled'
72
- end
73
-
74
- def test_trace_local_yield
75
- result = Vault::Tracing.trace_local('testing', opt: 'foo') { 1 + 1 }
76
- assert_equal 2, result, 'trace_local should yield the result of the block given'
77
- end
78
-
79
- def test_trace_local_calls_tracer
80
- tracer_mock = Minitest::Mock.new
81
- tracer_mock.expect :local_component_span, true, ['testing']
82
- Vault::Tracing.trace_local('testing', tracer_mock, opt: 'foo') { 1 + 1 }
83
- assert tracer_mock.verify,
84
- 'trace_local should call :local_component_span on the tracer'
85
- end
86
- end