aws-xray 0.32.2 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9339c52726c1286dc967332ebd1214d81dff09a7
4
- data.tar.gz: 85c8c3eecbd5b705e05975db29e893cdd809c309
3
+ metadata.gz: 86518cf5bf93669438808fdc243b85a0f008c6fb
4
+ data.tar.gz: d3f4dc26f179fcdac79c1e869dd3184bd205839e
5
5
  SHA512:
6
- metadata.gz: 1fec4a00dfae3a47a23f5263fbe8512cf447e9ef274518052c62078e58707a0ff014a5c7236ac844df8771574700ee9d4b6fae9938bb79ca828b6c4b0ff6cd3e
7
- data.tar.gz: '0668ff24b6871a361b87996111bb08883407988665aaca163e34b698dd5530a26b5b5b0d00eb9045e308199ac5fb35c32bd550040e28441ac00928f41180e0c5'
6
+ metadata.gz: 4e7b87167a284726f295ea77cd6f91f56c1729e4699708fac291e223c0f4b02c8727b557a631bd54fb78747b38bdce5a5036e5b8a833e0c57d69b82ecc50aea1
7
+ data.tar.gz: 3016ab09e4e9e956b3f7ad02411c945d95ae75449f043e4967cdcfdde9ebafff841b2b6a430c46b151514f93c5e79fab0c9408eb80afa92dc21b8bee395581b4
data/README.md CHANGED
@@ -215,6 +215,10 @@ Optionaly, aws-xray offers an error handler which integrats with Sentry. To use
215
215
  Aws::Xray.config.segment_sending_error_handler = Aws::Xray::ErrorHandlerWithSentry.new
216
216
  ```
217
217
 
218
+ ### Recording caller of HTTP requests
219
+ Set `Aws::Xray.config.record_caller_of_http_requests = true` if you want investigate the caller of specific HTTP requests.
220
+ It records caller of net/http and Faraday middleware.
221
+
218
222
  ## Development
219
223
 
220
224
  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.
@@ -0,0 +1,33 @@
1
+ module Aws
2
+ module Xray
3
+ module CallerBuilder
4
+ extend self
5
+
6
+ MAX_BACKTRACE_SIZE = 100
7
+
8
+ # Build caller stack trace data.
9
+ # @return [Hash] for metadata
10
+ def call
11
+ dir = (Dir.pwd + '/') rescue '/'
12
+ stack = caller
13
+
14
+ truncated = [stack.size - MAX_BACKTRACE_SIZE, 0].max
15
+ stack = stack[0..MAX_BACKTRACE_SIZE - 1].map do |s|
16
+ file, line, method_name = s.split(':')
17
+ {
18
+ path: file.sub(dir, ''),
19
+ line: line,
20
+ label: method_name,
21
+ }
22
+ end
23
+
24
+ {
25
+ caller: {
26
+ stack: stack,
27
+ truncated: truncated,
28
+ }
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -41,6 +41,7 @@ module Aws
41
41
  @worker = Aws::Xray::Worker::Configuration.new
42
42
  @sampling_rate = Float(ENV['AWS_XRAY_SAMPLING_RATE'] || 0.001)
43
43
  @solr_hook_name = 'solr'
44
+ @record_caller_of_http_requests = false
44
45
  end
45
46
 
46
47
  # @param [String] name Logical service name for this application.
@@ -103,6 +104,10 @@ module Aws
103
104
  # @param [String] solr_hook_name
104
105
  # @return [String]
105
106
  attr_accessor :solr_hook_name
107
+
108
+ # @param [Boolean] record_caller_of_http_requests
109
+ # @return [Boolean]
110
+ attr_accessor :record_caller_of_http_requests
106
111
  end
107
112
  end
108
113
  end
@@ -25,6 +25,7 @@ module Aws
25
25
  res = Context.current.disable_trace(:net_http) { @app.call(req_env) }
26
26
  res.on_complete do |res_env|
27
27
  sub.set_http_response_with_error(res_env.status, res_env.response_headers['Content-Length'], remote: true)
28
+ sub.add_metadata(CallerBuilder.call) if Aws::Xray.config.record_caller_of_http_requests
28
29
  end
29
30
  end
30
31
  end
@@ -30,6 +30,7 @@ module Aws
30
30
  res = request_without_aws_xray(req, *args, &block)
31
31
 
32
32
  sub.set_http_response_with_error(res.code.to_i, res['Content-Length'], remote: true)
33
+ sub.add_metadata(CallerBuilder.call) if Aws::Xray.config.record_caller_of_http_requests
33
34
  res
34
35
  end
35
36
  end
@@ -4,6 +4,7 @@ require 'aws/xray/request'
4
4
  require 'aws/xray/response'
5
5
  require 'aws/xray/error'
6
6
  require 'aws/xray/annotation_normalizer'
7
+ require 'aws/xray/caller_builder'
7
8
 
8
9
  module Aws
9
10
  module Xray
@@ -1,5 +1,5 @@
1
1
  module Aws
2
2
  module Xray
3
- VERSION = '0.32.2'
3
+ VERSION = '0.33.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-xray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.2
4
+ version: 0.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taiki Ono
@@ -250,6 +250,7 @@ files:
250
250
  - lib/aws-xray.rb
251
251
  - lib/aws/xray.rb
252
252
  - lib/aws/xray/annotation_normalizer.rb
253
+ - lib/aws/xray/caller_builder.rb
253
254
  - lib/aws/xray/cause.rb
254
255
  - lib/aws/xray/client.rb
255
256
  - lib/aws/xray/configuration.rb