aws-xray 0.18.0.beta3 → 0.19.0.beta1
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 +12 -0
- data/lib/aws/xray/configuration.rb +8 -0
- data/lib/aws/xray/context.rb +2 -2
- data/lib/aws/xray/trace.rb +17 -1
- data/lib/aws/xray/version.rb +1 -1
- 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: 9f0218d89ab6e56b753057c38781e756412ca766
|
4
|
+
data.tar.gz: 232fb91a69d318c535249803a4c1f292158b4331
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da3574d466ec8181955f4d3919c95240da461339c2ef101c33c8d34dd652b995b75ee5d00319302ee7f5e7513e3d3484e4d9d43d2cc08fbc2f043ffee37d08df
|
7
|
+
data.tar.gz: 277dedd93475c26178400807dfb2aaa7b8cf0c27e9cc032c815a52271fcc0848db66ec4dce0903a6b902f83257fed4469061c0428a4b9da8a180db60e8ea687a
|
data/README.md
CHANGED
@@ -16,6 +16,7 @@ AWS X-Ray is a ditributed tracing system. See more detail about AWS X-Ray at [of
|
|
16
16
|
- Tracing HTTP request/response.
|
17
17
|
- Tracing errors.
|
18
18
|
- Annotation and metadata support.
|
19
|
+
- Sampling support.
|
19
20
|
|
20
21
|
## Installation
|
21
22
|
|
@@ -142,6 +143,17 @@ For that case, pass `AWS_XRAY_LOCATION` environment variable to container to spe
|
|
142
143
|
docker run --link xray:xray --env AWS_XRAY_LOCATION=xray:2000 my-application
|
143
144
|
```
|
144
145
|
|
146
|
+
### Sampling
|
147
|
+
Sampling rate should be a float within 0 to 1. Both 0 and 1 are acceptable.
|
148
|
+
e.g. 0 means never sampled, 1 means always sampled, 0.3 means 30% of requests (or traces in not Rack app) will be sampled.
|
149
|
+
The default sampling rate is `0.001`, which means 0.1% of requests will be sampled.
|
150
|
+
|
151
|
+
Set sampling rate with `AWS_XRAY_SAMPLING_RATE` env var or:
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
Aws::Xray.config.sampling_rate = 0.1
|
155
|
+
```
|
156
|
+
|
145
157
|
### Excluded paths
|
146
158
|
To avoid tracing health checking requests, use "excluded paths" configuration.
|
147
159
|
|
@@ -90,6 +90,14 @@ module Aws
|
|
90
90
|
Aws::Xray::Worker.reset(conf)
|
91
91
|
conf
|
92
92
|
end
|
93
|
+
|
94
|
+
# Default is 0.1%.
|
95
|
+
# @return [Float]
|
96
|
+
def sampling_rate
|
97
|
+
@sampling_rate ||= Float(ENV['AWS_XRAY_SAMPLING_RATE'] || 0.001)
|
98
|
+
end
|
99
|
+
# @param [Float] sampling_rate
|
100
|
+
attr_writer :sampling_rate
|
93
101
|
end
|
94
102
|
end
|
95
103
|
end
|
data/lib/aws/xray/context.rb
CHANGED
@@ -88,7 +88,7 @@ module Aws
|
|
88
88
|
raise e
|
89
89
|
ensure
|
90
90
|
base_segment.finish
|
91
|
-
@client.send_segment(base_segment)
|
91
|
+
@client.send_segment(base_segment) if @trace.sampled?
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -107,7 +107,7 @@ module Aws
|
|
107
107
|
raise e
|
108
108
|
ensure
|
109
109
|
sub.finish
|
110
|
-
@client.send_segment(sub)
|
110
|
+
@client.send_segment(sub) if @trace.sampled?
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
data/lib/aws/xray/trace.rb
CHANGED
@@ -13,11 +13,27 @@ module Aws
|
|
13
13
|
def build_from_header_value(header_value, now = Time.now)
|
14
14
|
h = HeaderParser.parse(header_value)
|
15
15
|
root = h['Root'] || generate_root(now)
|
16
|
-
new(root: root, sampled: h['Sampled']
|
16
|
+
new(root: root, sampled: decide_sampling(h['Sampled']), parent: h['Parent'])
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
+
# Decide sample this request or not. At first, check parent's sampled
|
22
|
+
# and follow the value if it exists. Then decide sampled or not
|
23
|
+
# according to configured sampling_rate.
|
24
|
+
# @param [String,nil] value
|
25
|
+
# @return [Bloolean]
|
26
|
+
def decide_sampling(value)
|
27
|
+
case value
|
28
|
+
when '0'
|
29
|
+
false
|
30
|
+
when '1'
|
31
|
+
true
|
32
|
+
else
|
33
|
+
rand < Aws::Xray.config.sampling_rate
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
21
37
|
def generate_root(now)
|
22
38
|
"1-#{now.to_i.to_s(16)}-#{SecureRandom.hex(12)}"
|
23
39
|
end
|
data/lib/aws/xray/version.rb
CHANGED
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.
|
4
|
+
version: 0.19.0.beta1
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|