aws-xray 0.35.0 → 0.38.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
- SHA1:
3
- metadata.gz: de94539e68d8048e57af8669d4e448c4b19caf1b
4
- data.tar.gz: 30d076056f6d338963ff33ed62e3f26a9c0e949a
2
+ SHA256:
3
+ metadata.gz: 6ebaad8e050c5b8f917c956164dd5a7769c1c4dee5dd5ddb0d771899f4f2d451
4
+ data.tar.gz: 3574a9341bae80e8efef838287e6d0e42e8567c794ff5ffbbf45e4a5edbf29dc
5
5
  SHA512:
6
- metadata.gz: 9d3fc5b75c99b1968bcffb8421d5d70da6c78e15ae930a1f876df3a91f1b65af59f32397404e880cc7c6efe51b8376136af803356f2612347872438711c5b355
7
- data.tar.gz: 830f48dc665ea1b49e3406317c3a8ac7278a21e5c978a83b7978f514f3431669b5fd53a413c018a5dc087e29a84d88d630c7a738b6c8cc2f08e21800044c64f7
6
+ metadata.gz: 00fe3dd905a62456ebf301d7954650a9b53a4a8aff850372c2e278431ba6cca0de1ee9f7c822e8626d9da1ab6c8223356c8409ff9c180928893457b2594fcbd7
7
+ data.tar.gz: 634b7769eaca9aab5f17a0784d2da4e1144f93a88afdea3dd40344ea42cbe17a72c08fa82cc0209ddb67688a54e9667984376e3f46a6b8edf3d9a2b92fd7d89c
data/.travis.yml CHANGED
@@ -4,6 +4,6 @@ branches:
4
4
  only:
5
5
  - master
6
6
  rvm:
7
- - 2.2.7
8
- - 2.3
9
- - 2.4
7
+ - 2.6
8
+ - 2.7
9
+ - 3.0
data/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # CHANGELOG
2
2
  Only breaking or notable changes.
3
3
 
4
+ ## v0.38.0
5
+ - aws/xray/hooks/active_record was removed because it's not usable due to too many traces
6
+
4
7
  ## v0.34.0
5
8
  - Change default sampling rate from 0.1% to undefined. Please set proper sampling rate in your production system.
6
9
 
data/README.md CHANGED
@@ -23,7 +23,6 @@ aws-xray has full feautres to build and send tracing data to AWS X-Ray.
23
23
  - net/http
24
24
  - rack
25
25
  - faraday
26
- - activerecord
27
26
  - rsolr
28
27
 
29
28
  ## Getting started
@@ -127,7 +126,7 @@ Aws::Xray.config.segment_sending_error_handler = Aws::Xray::ErrorHandlerWithSent
127
126
  ```
128
127
 
129
128
  ### Recording caller of HTTP requests
130
- Set `Aws::Xray.config.record_caller_of_http_requests = true` if you want investigate the caller of specific HTTP requests.
129
+ Set `Aws::Xray.config.record_caller_of_http_requests = true` if you want to investigate the caller of specific HTTP requests.
131
130
  It records caller of net/http and Faraday middleware.
132
131
 
133
132
  ## Usage
@@ -217,11 +216,6 @@ response = Aws::Xray.overwrite(name: 'sns') do
217
216
  end
218
217
  ```
219
218
 
220
- #### activerecord hook
221
- `require 'aws/xray/hooks/active_record'`.
222
-
223
- Note this hook can record large amount of data.
224
-
225
219
  #### rsolr hook
226
220
  When you want to name solr requests, use this hook by require `aws/xray/hooks/rsolr`. The typical usecase is you use local haproxy to proxy to solr instances and you want to distinguish these requests from other reqeusts using local haproxy.
227
221
 
data/aws-xray.gemspec CHANGED
@@ -22,10 +22,10 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ['lib']
23
23
 
24
24
  spec.add_dependency 'rack'
25
- spec.add_development_dependency 'activerecord'
26
25
  spec.add_development_dependency 'bundler'
27
26
  spec.add_development_dependency 'coveralls'
28
27
  spec.add_development_dependency 'faraday'
28
+ spec.add_development_dependency 'irb'
29
29
  spec.add_development_dependency 'json-schema'
30
30
  spec.add_development_dependency 'pry-byebug'
31
31
  spec.add_development_dependency 'rack-test'
data/bump ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ level = ARGV.first
3
+ if level.nil?
4
+ warn "Example: #{__FILE__} (tiny|minor|major)"
5
+ exit 1
6
+ end
7
+
8
+ path = 'lib/aws/xray/version.rb'
9
+ regexp = /VERSION = '(.+)'.freeze$/
10
+ version = File.read(path).scan(regexp)[0][0]
11
+ version_strs = version.split('.')
12
+
13
+ if version_strs.size > 3
14
+ warn "Current version includes a prelease suffix, drop it: #{version}"
15
+ version_strs = version_strs[0..2]
16
+ end
17
+
18
+ case level
19
+ when 'tiny'
20
+ version_strs[2] = version_strs[2].to_i + 1
21
+ when 'minor'
22
+ version_strs[1] = version_strs[1].to_i + 1
23
+ version_strs[2] = 0
24
+ when 'major'
25
+ version_strs[0] = version_strs[0].to_i + 1
26
+ version_strs[1] = 0
27
+ version_strs[2] = 0
28
+ else
29
+ warn "Example: #{__FILE__} (tiny|minor|major)"
30
+ exit 1
31
+ end
32
+
33
+ next_version = version_strs.join('.')
34
+ File.write(path, File.read(path).gsub(regexp, "VERSION = '#{next_version}'.freeze"))
35
+ system('git', 'add', path)
36
+ system('git', 'commit', '-m', "v#{next_version}")
@@ -1,4 +1,3 @@
1
1
  require 'aws/xray'
2
- require 'aws/xray/hooks/active_record'
3
2
  require 'aws/xray/hooks/net_http'
4
3
  require 'aws/xray/hooks/rsolr'
data/lib/aws/xray/rack.rb CHANGED
@@ -25,6 +25,7 @@ module Aws
25
25
  trace = build_trace(env[TRACE_ENV])
26
26
  env[ORIGINAL_TRACE_ENV] = env[TRACE_ENV] if env[TRACE_ENV] # just for the record
27
27
  env[TRACE_ENV] = trace.to_header_value
28
+ record_context!(trace)
28
29
 
29
30
  Aws::Xray.trace(name: @name, trace: trace) do |seg|
30
31
  seg.set_http_request(Request.build_from_rack_env(env))
@@ -47,6 +48,13 @@ module Aws
47
48
  def excluded_path?(path)
48
49
  !!@excluded_paths.find {|p| p === path }
49
50
  end
51
+
52
+ def record_context!(trace)
53
+ ::Raven.tags_context(xray_sampled: trace.sampled? ? '1' : '0') if defined?(::Raven)
54
+ rescue => e
55
+ Aws::Xray.config.logger.error("#{e.message}\n#{e.backtrace.join("\n")}")
56
+ # Ignore the error
57
+ end
50
58
  end
51
59
  end
52
60
  end
@@ -5,7 +5,13 @@ module Aws
5
5
  class Railtie < ::Rails::Railtie
6
6
  initializer 'aws-xray.set_name' do |app|
7
7
  unless Aws::Xray.config.name
8
- app_name = app.class.parent_name.underscore.gsub(/(\/|_)/, '-')
8
+ klass = app.class
9
+ parent_name = if klass.respond_to?(:module_parent_name)
10
+ klass.module_parent_name
11
+ else
12
+ klass.parent_name
13
+ end
14
+ app_name = parent_name.underscore.gsub(/(\/|_)/, '-')
9
15
 
10
16
  if Rails.env.production?
11
17
  Aws::Xray.config.name = app_name
@@ -1,3 +1,5 @@
1
+ require 'stringio'
2
+
1
3
  module Aws
2
4
  module Xray
3
5
  # For test
@@ -1,5 +1,5 @@
1
1
  module Aws
2
2
  module Xray
3
- VERSION = '0.35.0'
3
+ VERSION = '0.38.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-xray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.0
4
+ version: 0.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taiki Ono
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activerecord
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: coveralls
56
+ name: faraday
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: faraday
70
+ name: irb
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -254,6 +254,7 @@ files:
254
254
  - aws-xray.gemspec
255
255
  - bin/console
256
256
  - bin/setup
257
+ - bump
257
258
  - example/Gemfile
258
259
  - example/Procfile
259
260
  - example/README.md
@@ -275,7 +276,6 @@ files:
275
276
  - lib/aws/xray/errors.rb
276
277
  - lib/aws/xray/faraday.rb
277
278
  - lib/aws/xray/header_parser.rb
278
- - lib/aws/xray/hooks/active_record.rb
279
279
  - lib/aws/xray/hooks/all.rb
280
280
  - lib/aws/xray/hooks/net_http.rb
281
281
  - lib/aws/xray/hooks/rsolr.rb
@@ -291,12 +291,11 @@ files:
291
291
  - lib/aws/xray/version.rb
292
292
  - lib/aws/xray/version_detector.rb
293
293
  - lib/aws/xray/worker.rb
294
- - prepare_release.rb
295
294
  homepage: https://github.com/taiki45/aws-xray
296
295
  licenses:
297
296
  - MIT
298
297
  metadata: {}
299
- post_install_message:
298
+ post_install_message:
300
299
  rdoc_options: []
301
300
  require_paths:
302
301
  - lib
@@ -311,9 +310,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
311
310
  - !ruby/object:Gem::Version
312
311
  version: '0'
313
312
  requirements: []
314
- rubyforge_project:
315
- rubygems_version: 2.6.11
316
- signing_key:
313
+ rubygems_version: 3.2.13
314
+ signing_key:
317
315
  specification_version: 4
318
316
  summary: The unofficial X-Ray Tracing SDK for Ruby.
319
317
  test_files: []
@@ -1,86 +0,0 @@
1
- require 'aws/xray'
2
- require 'active_record'
3
-
4
- module Aws
5
- module Xray
6
- module Hooks
7
- module ActiveRecord
8
- extend self
9
-
10
- IGNORE_NAMES = ['SCHEMA', 'ActiveRecord::SchemaMigration Load']
11
-
12
- # event has #name, #time, #end, #duration, #payload
13
- # payload has #sql, #name, #connection_id, #binds, #cached
14
- #
15
- # @param [ActiveSupport::Notifications::Event] e
16
- def record(e)
17
- return if IGNORE_NAMES.include?(e.payload[:name])
18
-
19
- if !e.payload[:cached] && Aws::Xray::Context.started?
20
- pool, con = fetch_connection_and_pool(e.payload[:connection_id])
21
- return if pool.nil? || con.nil?
22
- name = build_name(pool.spec)
23
- return unless name # skip when connected to default host (typycally localhost)
24
-
25
- Aws::Xray::Context.current.start_subsegment(name: name, remote: true) do |sub|
26
- sub.start(e.time)
27
- sub.finish(e.end)
28
- sub.set_sql(Aws::Xray::Sql.build(
29
- url: build_url(pool.spec),
30
- database_version: build_version(con),
31
- ))
32
- end
33
- end
34
- end
35
-
36
- private
37
-
38
- def fetch_connection_and_pool(id)
39
- pool, con = nil, nil
40
- ::ActiveRecord::Base.connection_handler.connection_pool_list.each do |p|
41
- p.connections.each do |c|
42
- if c.object_id == id
43
- pool, con = p, c
44
- end
45
- end
46
- end
47
- return pool, con
48
- end
49
-
50
- def build_name(spec)
51
- spec.config.with_indifferent_access[:host]
52
- end
53
-
54
- def build_url(spec)
55
- config = spec.config.with_indifferent_access
56
- adapter = config.delete(:adapter) || 'unknown'
57
- host = config.delete(:host) || 'localhost'
58
- port = config.delete(:port) || ''
59
- username = config.delete(:username) || ''
60
- database = config.delete(:database) || ''
61
- config.delete(:password)
62
- query = config.map {|k, v| "#{k}=#{v}" }.join('&')
63
- query_str = query.empty? ? '' : "?#{query}"
64
- "#{adapter}://#{username}@#{host}:#{port}/#{database}#{query_str}"
65
- end
66
-
67
- def build_version(con)
68
- if con.respond_to?(:version)
69
- if (v = con.version.instance_variable_get('@version'))
70
- v.join('.')
71
- else
72
- nil
73
- end
74
- else
75
- nil
76
- end
77
- end
78
- end
79
- end
80
- end
81
- end
82
-
83
- # maybe old version?
84
- ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
85
- Aws::Xray::Hooks::ActiveRecord.record(ActiveSupport::Notifications::Event.new(*args))
86
- end
data/prepare_release.rb DELETED
@@ -1,11 +0,0 @@
1
- after = ARGV.first
2
- if after.nil?
3
- $stderr.puts "Example: ruby #{__FILE__} v0.6.0"
4
- exit 1
5
- end
6
-
7
- path = 'lib/aws/xray/version.rb'
8
- version_str = after.gsub('v', '')
9
- File.write(path, File.read(path).gsub(/VERSION = '.+'$/, "VERSION = '#{version_str}'"))
10
- system('git', 'add', path)
11
- system('git', 'commit', '-m', after)