aws-xray 0.34.3 → 0.35.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: 532e479bf5d85136ef07b1797919d8b95f91c69a
4
- data.tar.gz: ad77b1e33115dfa9cad71098a396d36521dd11c7
3
+ metadata.gz: de94539e68d8048e57af8669d4e448c4b19caf1b
4
+ data.tar.gz: 30d076056f6d338963ff33ed62e3f26a9c0e949a
5
5
  SHA512:
6
- metadata.gz: 6a0e8a502c42fabb4b8462ab3168e4f35299e8b31a40aadde7e880a7d7e4e5ae0ff244777705f5b22d6bd9a832d3cf92b2e6e960c6f160c70b13fa35b43e443b
7
- data.tar.gz: d2e66a08d7c6211730b8138d57010dffa3d6f09fd12673afd70cd77475190153081d836dab7f6431ffe87bdb059edbb720dfaab4e938756da2b8070c4e3bc5ad
6
+ metadata.gz: 9d3fc5b75c99b1968bcffb8421d5d70da6c78e15ae930a1f876df3a91f1b65af59f32397404e880cc7c6efe51b8376136af803356f2612347872438711c5b355
7
+ data.tar.gz: 830f48dc665ea1b49e3406317c3a8ac7278a21e5c978a83b7978f514f3431669b5fd53a413c018a5dc087e29a84d88d630c7a738b6c8cc2f08e21800044c64f7
@@ -8,21 +8,16 @@ module Aws
8
8
  class << self
9
9
  # @param [Aws::Xray::Segment] segment
10
10
  def send_segment(segment)
11
- Aws::Xray.config.logger.debug("#{Thread.current}: Client.send_segment started")
12
- payload = %!{"format": "json", "version": 1}\n#{segment.to_json}\n!
13
-
14
11
  begin
15
12
  if Aws::Xray.config.client_options[:sock] # test env or not aws-xray is not enabled
16
- send_payload(payload)
17
- Aws::Xray.config.logger.debug("#{Thread.current}: Client.send_segment called #send_payload in the same thread")
13
+ send_(segment)
18
14
  else # production env
19
- Worker.post(payload)
20
- Aws::Xray.config.logger.debug("#{Thread.current}: Client.send_segment posted a job to worker")
15
+ Worker.post(segment)
21
16
  end
22
17
  rescue QueueIsFullError => e
23
18
  begin
24
19
  host, port = Aws::Xray.config.client_options[:host], Aws::Xray.config.client_options[:port]
25
- Aws::Xray.config.segment_sending_error_handler.call(e, payload, host: host, port: port)
20
+ Aws::Xray.config.segment_sending_error_handler.call(e, '', host: host, port: port)
26
21
  rescue Exception => e
27
22
  $stderr.puts("Error handler `#{Aws::Xray.config.segment_sending_error_handler}` raised an error: #{e}\n#{e.backtrace.join("\n")}")
28
23
  end
@@ -30,16 +25,18 @@ module Aws
30
25
  end
31
26
 
32
27
  # Will be called in other threads.
33
- # @param [String] payload
34
- def send_payload(payload)
35
- Aws::Xray.config.logger.debug("#{Thread.current}: Client#send_payload")
28
+ # @param [Aws::Xray::Segment] segment
29
+ def send_(segment)
30
+ Aws::Xray.config.logger.debug("#{Thread.current}: Client#send_")
31
+ payload = %!{"format": "json", "version": 1}\n#{segment.to_json}\n!
32
+
36
33
  sock = Aws::Xray.config.client_options[:sock] || UDPSocket.new
37
34
  host, port = Aws::Xray.config.client_options[:host], Aws::Xray.config.client_options[:port]
38
35
 
39
36
  begin
40
37
  len = sock.send(payload, Socket::MSG_DONTWAIT, host, port)
41
38
  raise CanNotSendAllByteError.new(payload.bytesize, len) if payload.bytesize != len
42
- Aws::Xray.config.logger.debug("#{Thread.current}: Client#send_payload successfully sent payload, len=#{len}")
39
+ Aws::Xray.config.logger.debug("#{Thread.current}: Client#send_ successfully sent payload, len=#{len}")
43
40
  len
44
41
  rescue SystemCallError, SocketError, CanNotSendAllByteError => e
45
42
  begin
@@ -1,5 +1,5 @@
1
1
  module Aws
2
2
  module Xray
3
- VERSION = '0.34.3'
3
+ VERSION = '0.35.0'
4
4
  end
5
5
  end
@@ -13,13 +13,13 @@ module Aws
13
13
  @post_lock = ::Mutex.new
14
14
  @pid = $$
15
15
  class << self
16
- # @param [String] payload to send
16
+ # @param [Aws::Xray::Segment] segment to send
17
17
  # @param [Aws::Xray::Client] client
18
- def post(payload)
18
+ def post(segment)
19
19
  Aws::Xray.config.logger.debug("#{Thread.current}: Worker.post received a job")
20
20
  @post_lock.synchronize do
21
21
  refresh_if_forked
22
- @queue.push(payload)
22
+ @queue.push(segment)
23
23
  end
24
24
  Aws::Xray.config.logger.debug("#{Thread.current}: Worker.post pushed a job")
25
25
  rescue ThreadError => e
@@ -51,11 +51,11 @@ module Aws
51
51
  th = Thread.new(@queue) do |queue|
52
52
  loop do
53
53
  Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run waits a job")
54
- payload = queue.pop
54
+ segment = queue.pop
55
55
  Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run received a job")
56
- if payload
57
- Client.send_payload(payload.to_s)
58
- Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run sent a payload")
56
+ if segment
57
+ Client.send_(segment)
58
+ Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run sent a segment")
59
59
  else
60
60
  Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run received invalid item, ignored it")
61
61
  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.34.3
4
+ version: 0.35.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taiki Ono