vault-tools 1.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
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: 1.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Continanza
8
8
  - Jamu Kakar
9
- autorequire:
9
+ - Kenny Parnell
10
+ autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2018-11-21 00:00:00.000000000 Z
13
+ date: 2021-08-26 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: scrolls
@@ -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
  - - "~>"
@@ -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,16 +210,18 @@ 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: []
247
222
  files:
223
+ - ".circleci/config.yml"
248
224
  - ".gitignore"
249
- - ".travis.yml"
250
225
  - ".yardopts"
251
226
  - Gemfile
252
227
  - Gemfile.lock
@@ -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,14 +264,13 @@ 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
299
270
  homepage: ''
300
271
  licenses: []
301
272
  metadata: {}
302
- post_install_message:
273
+ post_install_message:
303
274
  rdoc_options: []
304
275
  require_paths:
305
276
  - lib
@@ -307,16 +278,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
307
278
  requirements:
308
279
  - - ">="
309
280
  - !ruby/object:Gem::Version
310
- version: '0'
281
+ version: 2.7.1
311
282
  required_rubygems_version: !ruby/object:Gem::Requirement
312
283
  requirements:
313
284
  - - ">="
314
285
  - !ruby/object:Gem::Version
315
286
  version: '0'
316
287
  requirements: []
317
- rubyforge_project:
318
- rubygems_version: 2.7.6
319
- signing_key:
288
+ rubygems_version: 3.1.2
289
+ signing_key:
320
290
  specification_version: 4
321
291
  summary: Test classes, base web classes, and helpers - oh my!
322
292
  test_files: []
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.5.0
5
- - 2.4.0
6
- - 2.3.0
@@ -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,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
data/test/tracing_test.rb DELETED
@@ -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