aws-xray 0.19.0.beta1 → 0.19.0.beta2
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 +4 -4
- data/README.md +1 -1
- data/lib/aws/xray.rb +3 -0
- data/lib/aws/xray/client.rb +5 -0
- data/lib/aws/xray/configuration.rb +8 -0
- data/lib/aws/xray/version.rb +1 -1
- data/lib/aws/xray/worker.rb +6 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04bfc0455b6d3432e76d99375ae6f13a4a025d2d
|
4
|
+
data.tar.gz: 62f8cd7d1a8987845e7ac16830c2ef2d8ae1aeac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0fff3ec264805f7308d72d0ec04482b68b389a180e07bc5d2e18d2ac5a32659808499f6a67504b3839220d03b59bcad3f24a137c979dd54129553f1ee1ccafb
|
7
|
+
data.tar.gz: 72b263ce13cec59bceaeac920c9218109a5b58f4a2b8e5bfa74e4345fc565793ec71c868486a6fabbfad5ab8ad1f1a6c91cf5f506c58523013a159f778096fc2
|
data/README.md
CHANGED
@@ -133,7 +133,7 @@ end
|
|
133
133
|
|
134
134
|
## Configurations
|
135
135
|
### X-Ray agent location
|
136
|
-
aws-xray does not send any trace data
|
136
|
+
aws-xray does not send any trace data by default. Set `AWS_XRAY_LOCATION` environment variable like `AWS_XRAY_LOCATION=localhost:2000`
|
137
137
|
or set proper aws-agent location with configuration interface like `Aws::Xray.config.client_options = { host: "localhost", port: 2000 }`.
|
138
138
|
|
139
139
|
In container environments, we often run xray agent container beside application container.
|
data/lib/aws/xray.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
1
3
|
require 'aws/xray/version'
|
2
4
|
require 'aws/xray/errors'
|
3
5
|
require 'aws/xray/trace'
|
@@ -19,6 +21,7 @@ module Aws
|
|
19
21
|
class << self
|
20
22
|
attr_reader :config
|
21
23
|
end
|
24
|
+
Worker.reset(Worker::Configuration.new)
|
22
25
|
|
23
26
|
# @param [String] name a logical name of this tracing context.
|
24
27
|
def self.trace(name: nil)
|
data/lib/aws/xray/client.rb
CHANGED
@@ -18,13 +18,16 @@ module Aws
|
|
18
18
|
# When UDPSocket#send can not send all bytes, just give up it.
|
19
19
|
# @param [Aws::Xray::Segment] segment
|
20
20
|
def send_segment(segment)
|
21
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Client#send_segment started")
|
21
22
|
payload = %!{"format": "json", "version": 1}\n#{segment.to_json}\n!
|
22
23
|
|
23
24
|
begin
|
24
25
|
if @sock # test env or not aws-xray is not enabled
|
25
26
|
send_payload(payload)
|
27
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Client#send_segment called #send_payload in the same thread")
|
26
28
|
else # production env
|
27
29
|
Worker.post(payload, self.copy)
|
30
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Client#send_segment posted a job to worker")
|
28
31
|
end
|
29
32
|
rescue QueueIsFullError => e
|
30
33
|
begin
|
@@ -38,11 +41,13 @@ module Aws
|
|
38
41
|
# Will be called in other threads.
|
39
42
|
# @param [String] payload
|
40
43
|
def send_payload(payload)
|
44
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Client#send_payload")
|
41
45
|
sock = @sock || UDPSocket.new
|
42
46
|
|
43
47
|
begin
|
44
48
|
len = sock.send(payload, Socket::MSG_DONTWAIT, @host, @port)
|
45
49
|
raise CanNotSendAllByteError.new(payload.size, len) if payload.size != len
|
50
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Client#send_payload successfully sent payload, len=#{len}")
|
46
51
|
len
|
47
52
|
rescue SystemCallError, SocketError, CanNotSendAllByteError => e
|
48
53
|
begin
|
@@ -7,6 +7,10 @@ module Aws
|
|
7
7
|
module Xray
|
8
8
|
# thread-unsafe, suppose to be used only in initialization phase.
|
9
9
|
class Configuration
|
10
|
+
def initialize
|
11
|
+
@logger = ::Logger.new($stdout).tap {|l| l.level = Logger::INFO }
|
12
|
+
end
|
13
|
+
|
10
14
|
# @return [String] name Logical service name for this application.
|
11
15
|
def name
|
12
16
|
@name ||= ENV['AWS_XRAY_NAME']
|
@@ -98,6 +102,10 @@ module Aws
|
|
98
102
|
end
|
99
103
|
# @param [Float] sampling_rate
|
100
104
|
attr_writer :sampling_rate
|
105
|
+
|
106
|
+
# @param [Logger] logger
|
107
|
+
# @return [Logger]
|
108
|
+
attr_accessor :logger
|
101
109
|
end
|
102
110
|
end
|
103
111
|
end
|
data/lib/aws/xray/version.rb
CHANGED
data/lib/aws/xray/worker.rb
CHANGED
@@ -17,7 +17,9 @@ module Aws
|
|
17
17
|
# @param [String] payload to send
|
18
18
|
# @param [Aws::Xray::Client] client
|
19
19
|
def post(payload, client)
|
20
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Worker.post received a job")
|
20
21
|
@queue.push(Item.new(payload, client.copy))
|
22
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Worker.post pushed a job")
|
21
23
|
rescue ThreadError => e
|
22
24
|
raise QueueIsFullError.new(e)
|
23
25
|
end
|
@@ -38,19 +40,20 @@ module Aws
|
|
38
40
|
def run
|
39
41
|
th = Thread.new(@queue) do |queue|
|
40
42
|
loop do
|
43
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run waits a job")
|
41
44
|
item = queue.pop
|
45
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run received a job")
|
42
46
|
if item.is_a?(Item)
|
43
47
|
item.client.send_payload(item.payload)
|
48
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run sent a payload")
|
44
49
|
else
|
45
|
-
#
|
50
|
+
Aws::Xray.config.logger.debug("#{Thread.current}: Worker#run received invalid item, ignored it")
|
46
51
|
end
|
47
52
|
end
|
48
53
|
end
|
49
54
|
th.abort_on_exception = true
|
50
55
|
th
|
51
56
|
end
|
52
|
-
|
53
|
-
reset(Aws::Xray::Worker::Configuration.new)
|
54
57
|
end
|
55
58
|
end
|
56
59
|
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.19.0.
|
4
|
+
version: 0.19.0.beta2
|
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-
|
11
|
+
date: 2017-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|