aws-xray 0.37.1 → 0.39.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: af7b77e24f5f52985838b57d93790ac4e070ef16
4
- data.tar.gz: 3698224665b0676507b3e6c60e2bd09ab99b5cb5
2
+ SHA256:
3
+ metadata.gz: 10edc8cd3e2fb395697400fc98d9bf23e19612672fd4052292113d1d114aef5d
4
+ data.tar.gz: bb02ea13f5125df8ba5d7170efc42c71cccef6b3192a4f10227c1a3053f9718d
5
5
  SHA512:
6
- metadata.gz: 0e49d7f911912787e94dfba13a260a64ec2bfc31bdbb4f4fd50de666871dec086affdf43936694e774f716437670d42e98fad89fcfb1bf281c10dffd052a844f
7
- data.tar.gz: dfd2ae23e980676923521a0049ce7e49e6d78bda17aa1e11cf2dac2d33fbd939bf8eb7c942323e745532afff632d6e1f0a821acb959b8600db216294d784d13e
6
+ metadata.gz: def8ffbb94e688612fbf9f123bb0808fcedaa83eb0e00b92ff29ee9cd4ec22e87e909c7f7893aa1690884b73c285defb564c2ca6863a4d63ee0f5775c633bce8
7
+ data.tar.gz: b7798a486132e087de6cd143639c89d9a004d2a898f886d27b3937f27c4abe13ba8227063c2b7e20b16719e6fbd374376ce1e572602001fd2661650d145da277
@@ -0,0 +1,24 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby:
14
+ - '2.6'
15
+ - '2.7'
16
+ - '3.0'
17
+ name: Run test with Ruby ${{ matrix.ruby }}
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
24
+ - run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # CHANGELOG
2
2
  Only breaking or notable changes.
3
3
 
4
+ ## v0.39.0
5
+ - `ErrorHandlerWithSentry` now supports `sentry-ruby` gem.
6
+
7
+ ## v0.38.0
8
+ - aws/xray/hooks/active_record was removed because it's not usable due to too many traces
9
+
4
10
  ## v0.34.0
5
11
  - Change default sampling rate from 0.1% to undefined. Please set proper sampling rate in your production system.
6
12
 
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # aws-xray
2
- [![Build Status](https://travis-ci.org/taiki45/aws-xray.svg?branch=master)](https://travis-ci.org/taiki45/aws-xray)
2
+ [![Build Status](https://github.com/cookpad/aws-xray/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/cookpad/aws-xray/actions/workflows/ci.yml)
3
3
  [![Gem Version](https://badge.fury.io/rb/aws-xray.svg)](https://badge.fury.io/rb/aws-xray)
4
4
  [![Coverage Status](https://coveralls.io/repos/github/taiki45/aws-xray/badge.svg)](https://coveralls.io/github/taiki45/aws-xray)
5
5
  [![Inline docs](http://inch-ci.org/github/taiki45/aws-xray.svg?branch=master)](http://inch-ci.org/github/taiki45/aws-xray)
@@ -11,7 +11,7 @@ AWS X-Ray is a distributed tracing system. See more detail about AWS X-Ray at [o
11
11
  If you want to know what is distributed tracing, what is problems behind, etc.., please refer [Google's Dapper paper](https://research.google.com/pubs/pub36356.html).
12
12
 
13
13
  ## Features
14
- aws-xray has full feautres to build and send tracing data to AWS X-Ray.
14
+ aws-xray has full features to build and send tracing data to AWS X-Ray.
15
15
 
16
16
  - Propagation support in both single and multi thread environments.
17
17
  - Instrumentation for major libraries.
@@ -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
@@ -196,8 +195,6 @@ You can enable all the hooks with:
196
195
  gem 'aws-xray', require: 'aws/xray/hooks/all'
197
196
  ```
198
197
 
199
- NOTE: activerecord hook won't be enabled by this because the hook may produce lots of trace records.
200
-
201
198
  #### net/http hook
202
199
  To monkey patch net/http and records out-going http requests automatically, just require `aws/xray/hooks/net_http`:
203
200
 
@@ -219,11 +216,6 @@ response = Aws::Xray.overwrite(name: 'sns') do
219
216
  end
220
217
  ```
221
218
 
222
- #### activerecord hook
223
- `require 'aws/xray/hooks/active_record'`.
224
-
225
- Note this hook can record large amount of data.
226
-
227
219
  #### rsolr hook
228
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.
229
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'
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency 'rsolr'
35
35
  spec.add_development_dependency 'rspec'
36
36
  spec.add_development_dependency 'sentry-raven'
37
+ spec.add_development_dependency 'sentry-ruby'
37
38
  spec.add_development_dependency 'simplecov'
38
39
  spec.add_development_dependency 'sqlite3'
39
40
  spec.add_development_dependency 'webmock'
@@ -21,12 +21,30 @@ Error: #{error}
21
21
  end
22
22
  end
23
23
 
24
- # Must be configured sentry-raven gem.
24
+ # Must be configured sentry-raven or sentry-ruby gem.
25
25
  class ErrorHandlerWithSentry
26
+ class MissingSentryError < StandardError; end
27
+
28
+ def initialize
29
+ if !defined?(::Sentry) && !defined?(::Raven)
30
+ raise MissingSentryError.new('Must be installed sentry-raven or sentry-ruby gem')
31
+ end
32
+ end
33
+
26
34
  ERROR_LEVEL = 'warning'.freeze
27
35
 
28
36
  def call(error, payload, host:, port:)
29
- ::Raven.capture_exception(
37
+ if defined?(::Raven)
38
+ ::Raven.capture_exception(
39
+ error,
40
+ level: ERROR_LEVEL,
41
+ extra: { 'payload' => payload, 'payload_raw' => payload.unpack('H*').first }
42
+ )
43
+
44
+ return
45
+ end
46
+
47
+ ::Sentry.capture_exception(
30
48
  error,
31
49
  level: ERROR_LEVEL,
32
50
  extra: { 'payload' => payload, 'payload_raw' => payload.unpack('H*').first }
@@ -1,4 +1,3 @@
1
- # Don't require activerecord hook because the hook may produce lots of trace records.
2
1
  require 'aws/xray'
3
2
  require 'aws/xray/hooks/net_http'
4
3
  require 'aws/xray/hooks/rsolr'
@@ -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.37.1'.freeze
3
+ VERSION = '0.39.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.37.1
4
+ version: 0.39.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-11-14 00:00:00.000000000 Z
11
+ date: 2022-05-23 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
  - - ">="
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: sentry-ruby
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: simplecov
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -241,9 +255,9 @@ executables: []
241
255
  extensions: []
242
256
  extra_rdoc_files: []
243
257
  files:
258
+ - ".github/workflows/ci.yml"
244
259
  - ".gitignore"
245
260
  - ".rspec"
246
- - ".travis.yml"
247
261
  - CHANGELOG.md
248
262
  - CONTRIBUTING.md
249
263
  - Gemfile
@@ -276,7 +290,6 @@ files:
276
290
  - lib/aws/xray/errors.rb
277
291
  - lib/aws/xray/faraday.rb
278
292
  - lib/aws/xray/header_parser.rb
279
- - lib/aws/xray/hooks/active_record.rb
280
293
  - lib/aws/xray/hooks/all.rb
281
294
  - lib/aws/xray/hooks/net_http.rb
282
295
  - lib/aws/xray/hooks/rsolr.rb
@@ -296,7 +309,7 @@ homepage: https://github.com/taiki45/aws-xray
296
309
  licenses:
297
310
  - MIT
298
311
  metadata: {}
299
- post_install_message:
312
+ post_install_message:
300
313
  rdoc_options: []
301
314
  require_paths:
302
315
  - lib
@@ -311,9 +324,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
311
324
  - !ruby/object:Gem::Version
312
325
  version: '0'
313
326
  requirements: []
314
- rubyforge_project:
315
- rubygems_version: 2.5.2.1
316
- signing_key:
327
+ rubygems_version: 3.2.32
328
+ signing_key:
317
329
  specification_version: 4
318
330
  summary: The unofficial X-Ray Tracing SDK for Ruby.
319
331
  test_files: []
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- branches:
4
- only:
5
- - master
6
- rvm:
7
- - 2.2.7
8
- - 2.3
9
- - 2.4
@@ -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