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 +4 -4
- data/lib/aws/xray/client.rb +9 -12
- data/lib/aws/xray/version.rb +1 -1
- data/lib/aws/xray/worker.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de94539e68d8048e57af8669d4e448c4b19caf1b
|
4
|
+
data.tar.gz: 30d076056f6d338963ff33ed62e3f26a9c0e949a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d3fc5b75c99b1968bcffb8421d5d70da6c78e15ae930a1f876df3a91f1b65af59f32397404e880cc7c6efe51b8376136af803356f2612347872438711c5b355
|
7
|
+
data.tar.gz: 830f48dc665ea1b49e3406317c3a8ac7278a21e5c978a83b7978f514f3431669b5fd53a413c018a5dc087e29a84d88d630c7a738b6c8cc2f08e21800044c64f7
|
data/lib/aws/xray/client.rb
CHANGED
@@ -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
|
-
|
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(
|
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,
|
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 [
|
34
|
-
def
|
35
|
-
Aws::Xray.config.logger.debug("#{Thread.current}: Client#
|
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#
|
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
|
data/lib/aws/xray/version.rb
CHANGED
data/lib/aws/xray/worker.rb
CHANGED
@@ -13,13 +13,13 @@ module Aws
|
|
13
13
|
@post_lock = ::Mutex.new
|
14
14
|
@pid = $$
|
15
15
|
class << self
|
16
|
-
# @param [
|
16
|
+
# @param [Aws::Xray::Segment] segment to send
|
17
17
|
# @param [Aws::Xray::Client] client
|
18
|
-
def post(
|
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(
|
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
|
-
|
54
|
+
segment = queue.pop
|
55
55
|
Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run received a job")
|
56
|
-
if
|
57
|
-
Client.
|
58
|
-
Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run sent a
|
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
|