aws-xray 0.16.5 → 0.17.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: 7928f5c7fd83ac39e46cbb525539c50e0c448e99
4
- data.tar.gz: 1fb21ce7a1aa3b9ed5598eb2ca2664351ea16c78
3
+ metadata.gz: 4662c7e02f96d99ec218697501619aafc62a6e42
4
+ data.tar.gz: 21600a8fce7aa843e712b31f0ca7417bf9cc6a3c
5
5
  SHA512:
6
- metadata.gz: ef131aa7abd38587411272edf8ea1092907f365e391b1582000ec78977c4ab10fd766a239845d4c6e5c71e456660102276aa9e953154f4504f4b7a5d26b0b510
7
- data.tar.gz: 2d44467d2051f591d94e70a133b46ab8d377d160880ea28b1e0c9d879870578efd682897bfb5500581f7873c879036b2cfe6bd32c3c28019d224e528dabe7a70
6
+ metadata.gz: 05dd8e836d6149bcbdfd04338103abb82baa82a084dd89b6b77c95a45648d5250ca41637456cff69a38753ce9bc582bad9c2134f7e31f470bf6bfa050f0e5459
7
+ data.tar.gz: d419d7eacc9e52d05ebbbf068fb795133b87d67fed9997036c39502dad95ac0907927b40d46b2c6d115b18dccf67c0e45f4b41d1f1208fe4c40bb2b0326ee45d
data/README.md CHANGED
@@ -124,8 +124,9 @@ Tracing context is thread local. To pass current tracing context, copy current t
124
124
 
125
125
  ```ruby
126
126
  Thread.new(Aws::Xray::Context.current.copy) do |context|
127
- Aws::Xray::Context.set_current(context)
128
- # Do something
127
+ Aws::Xray::Context.with_given_context(context) do
128
+ # Do something
129
+ end
129
130
  end
130
131
  ```
131
132
 
@@ -175,6 +176,22 @@ Aws::Xray.config.default_metadata = Aws::Xray.config.default_metadata.merge(key:
175
176
 
176
177
  Note: See official document about annotation and metadata in AWS X-Ray.
177
178
 
179
+ ### Error handlers
180
+ When aws-xray fails to send segments due to system call errors, it logs errors to stderr by default.
181
+ If you want to track these errors, for example with Sentry, you can configure your own error handler:
182
+
183
+ ```ruby
184
+ Aws::Xray.config.segment_sending_error_handler = MyCustomErrorHandler.new
185
+ ```
186
+
187
+ The error handler must be callable object and receive 2 arguments and 2 keyword arguments. See `Aws::Xray::DefaultErrorHandler` more detail.
188
+
189
+ Optionaly, aws-xray offers an error handler which integrats with Sentry. To use it:
190
+
191
+ ```ruby
192
+ Aws::Xray.config.segment_sending_error_handler = ErrorHandlerWithSentry.new
193
+ ```
194
+
178
195
  ## Development
179
196
 
180
197
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -25,13 +25,11 @@ module Aws
25
25
  len = sock.send(payload, 0, @host, @port)
26
26
  $stderr.puts("Can not send all bytes: #{len} sent") if payload.size != len
27
27
  rescue SystemCallError, SocketError => e
28
- $stderr.puts(<<-EOS)
29
- Failed to send a segment:
30
- Segnemt:
31
- #{payload}
32
- Error: #{e}
33
- #{e.backtrace.join("\n")}
34
- EOS
28
+ begin
29
+ Aws::Xray.config.segment_sending_error_handler.call(e, payload, host: @host, port: @port)
30
+ rescue Exception => e
31
+ $stderr.puts("Error handler `#{Aws::Xray.config.segment_sending_error_handler}` raised an error: #{e}\n#{e.backtrace.join("\n")}")
32
+ end
35
33
  ensure
36
34
  sock.close
37
35
  end
@@ -1,6 +1,7 @@
1
1
  require 'socket'
2
2
  require 'aws/xray/annotation_normalizer'
3
3
  require 'aws/xray/version_detector'
4
+ require 'aws/xray/error_handlers'
4
5
 
5
6
  module Aws
6
7
  module Xray
@@ -70,6 +71,12 @@ module Aws
70
71
  end
71
72
  # @param [Hash] metadata Default metadata.
72
73
  attr_writer :default_metadata
74
+
75
+ def segment_sending_error_handler
76
+ @segment_sending_error_handler ||= DefaultErrorHandler.new($stderr)
77
+ end
78
+ # @param [Proc] segment_sending_error_handler Callable object
79
+ attr_writer :segment_sending_error_handler
73
80
  end
74
81
  end
75
82
  end
@@ -0,0 +1,35 @@
1
+ module Aws
2
+ module Xray
3
+ class DefaultErrorHandler
4
+ # @param [IO] io
5
+ def initialize(io)
6
+ @io = io
7
+ end
8
+
9
+ # @param [Exception] error
10
+ # @param [String] payload
11
+ # @param [String,nil] host
12
+ # @param [Integer,nil] port
13
+ def call(error, payload, host:, port:)
14
+ @io.puts(<<-EOS)
15
+ Failed to send a segment to #{host}:#{port}:
16
+ Segnemt:
17
+ #{payload}
18
+ Error: #{error}
19
+ #{error.backtrace.join("\n")}
20
+ EOS
21
+ end
22
+ end
23
+
24
+ # Must be configured sentry-raven gem.
25
+ class ErrorHandlerWithSentry
26
+ def call(error, payload, host:, port:)
27
+ if defined?(Raven)
28
+ ::Raven.capture_exception(error)
29
+ else
30
+ $stderr.puts('ErrorHandlerWithSentry is configured but `Raven` is undefined.')
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,5 +1,5 @@
1
1
  module Aws
2
2
  module Xray
3
- VERSION = '0.16.5'
3
+ VERSION = '0.17.0'
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.16.5
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taiki Ono
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-13 00:00:00.000000000 Z
11
+ date: 2017-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -156,6 +156,7 @@ files:
156
156
  - lib/aws/xray/configuration.rb
157
157
  - lib/aws/xray/context.rb
158
158
  - lib/aws/xray/error.rb
159
+ - lib/aws/xray/error_handlers.rb
159
160
  - lib/aws/xray/faraday.rb
160
161
  - lib/aws/xray/header_parser.rb
161
162
  - lib/aws/xray/hooks/all.rb
@@ -191,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  version: '0'
192
193
  requirements: []
193
194
  rubyforge_project:
194
- rubygems_version: 2.5.2
195
+ rubygems_version: 2.6.11
195
196
  signing_key:
196
197
  specification_version: 4
197
198
  summary: The unofficial X-Ray Tracing SDK for Ruby.