aws-xray 0.14.0 → 0.15.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 +4 -4
- data/README.md +31 -1
- data/lib/aws/xray/context.rb +1 -1
- data/lib/aws/xray/hooks/all.rb +1 -0
- data/lib/aws/xray/hooks/net_http.rb +4 -1
- data/lib/aws/xray/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 299ef3e4e20724f082b232846ec09d48257cf4e7
|
4
|
+
data.tar.gz: d66f81590342387f0dcdf80981aea4ec95fd9449
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 364d93ef9043a99cc26383d1d6fe5f563fa580b9aaa2b4b7fc733eb4089de5602a66c8c61b002c2e2a7c7c92d6525ced5b12b7e461602a00f402c05a621ac8e8
|
7
|
+
data.tar.gz: 90c80537e55f225c5d797684e10472e56f617c6e5c7b3a9edcf237da933966dc82e9a6fa7f5068466e787733871f23811a336591fd32d47107701c355db8686c
|
data/README.md
CHANGED
@@ -8,9 +8,10 @@ It enables you to capture in-coming HTTP requests and out-going HTTP requests an
|
|
8
8
|
AWS X-Ray is a ditributed tracing system. See more detail about AWS X-Ray at [official document](http://docs.aws.amazon.com/xray/latest/devguide/aws-xray.html).
|
9
9
|
|
10
10
|
## Features
|
11
|
+
- Propagatin support in both single and multi thread environment.
|
11
12
|
- Rack middleware.
|
12
13
|
- Faraday middleware.
|
13
|
-
-
|
14
|
+
- net/http hook.
|
14
15
|
- Tracing HTTP request/response.
|
15
16
|
- Tracing errors.
|
16
17
|
- Annotation and metadata support.
|
@@ -88,6 +89,35 @@ Aws::Xray.trace(name: 'my-app-batch') do |seg|
|
|
88
89
|
end
|
89
90
|
```
|
90
91
|
|
92
|
+
### Hooks
|
93
|
+
You can enable all the hooks with:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
# Gemfile
|
97
|
+
gem 'aws-xray', require: 'aws/xray/hooks/all'
|
98
|
+
```
|
99
|
+
|
100
|
+
#### net/http hook
|
101
|
+
To monkey patch net/http and records out-going http requests automatically, just require `aws/xray/hooks/net_http`:
|
102
|
+
|
103
|
+
If you can pass headers for net/http client, you can setup subsegment name via `X-Aws-Xray-Name` header:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
Net::HTTP.start(host, port) do |http|
|
107
|
+
req = Net::HTTP::Get.new(uri, { 'X-Aws-Xray-Name' => 'target-app' })
|
108
|
+
http.request(req)
|
109
|
+
end
|
110
|
+
```
|
111
|
+
|
112
|
+
If you can't access headers, e.g. external client library like aws-sdk or dogapi-rb, setup subsegment name by `Aws::Xray::Context#overwrite`:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
client = Aws::Sns::Client.new
|
116
|
+
response = Aws::Xray::Context.current.overwrite(name: 'sns') do
|
117
|
+
client.create_topic(...)
|
118
|
+
end
|
119
|
+
```
|
120
|
+
|
91
121
|
### Multi threaded environment
|
92
122
|
Tracing context is thread local. To pass current tracing context, copy current tracing context:
|
93
123
|
|
data/lib/aws/xray/context.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require 'aws/xray/hooks/net_http'
|
@@ -4,6 +4,8 @@ module Aws
|
|
4
4
|
module Xray
|
5
5
|
module Hooks
|
6
6
|
module NetHttp
|
7
|
+
NAME_HEADER = 'X-Aws-Xray-Name'.freeze
|
8
|
+
|
7
9
|
def request(req, *args)
|
8
10
|
return super unless Context.started?
|
9
11
|
return super if Context.current.disabled?(:net_http)
|
@@ -18,7 +20,8 @@ module Aws
|
|
18
20
|
url: uri.to_s,
|
19
21
|
user_agent: req['User-Agent'],
|
20
22
|
)
|
21
|
-
|
23
|
+
name = req[NAME_HEADER] || req['Host'] || address
|
24
|
+
Context.current.child_trace(remote: true, name: name) do |sub|
|
22
25
|
propagate_trace = sub.generate_trace
|
23
26
|
req[TRACE_HEADER] = propagate_trace.to_header_value
|
24
27
|
sub.set_http_request(request_record)
|
data/lib/aws/xray/version.rb
CHANGED
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.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taiki Ono
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/aws/xray/error.rb
|
145
145
|
- lib/aws/xray/faraday.rb
|
146
146
|
- lib/aws/xray/header_parser.rb
|
147
|
+
- lib/aws/xray/hooks/all.rb
|
147
148
|
- lib/aws/xray/hooks/net_http.rb
|
148
149
|
- lib/aws/xray/rack.rb
|
149
150
|
- lib/aws/xray/rails.rb
|