aws-xray 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/README.md +8 -2
- data/aws-xray.gemspec +1 -0
- data/lib/aws/xray/configuration.rb +16 -1
- data/lib/aws/xray/rack.rb +13 -3
- data/lib/aws/xray/rails.rb +9 -1
- data/lib/aws/xray/segment.rb +1 -1
- data/lib/aws/xray/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e3c5e5103576cdd8082e34375764847e25f0ba3
|
4
|
+
data.tar.gz: fd6877a751905e3387625c230f9f7615a1265035
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c31717fe55d97fa6fc548f06f4ca827fd08b60fe61f4c055dc16d85ede43188e2ce1bdc34e8773e0de71a6a6155950c7544424773c72a52e0e3653c653b6db
|
7
|
+
data.tar.gz: 2efe2933ccd9ca9cb31e9367115fca96ebdd6ee30f3f9cfb42b0e8689009700f77c129b8cb4d123fba61517741e0cb4f34d3d33674edd01f80e0cf8de9309d30
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -98,7 +98,7 @@ end
|
|
98
98
|
```
|
99
99
|
|
100
100
|
## Configurations
|
101
|
-
###
|
101
|
+
### X-Ray agent location
|
102
102
|
In container environments, we often run xray agent container beside application container.
|
103
103
|
For that case, pass `AWS_XRAY_LOCATION` environment variable to container to specify host and port of xray agent.
|
104
104
|
|
@@ -106,7 +106,13 @@ For that case, pass `AWS_XRAY_LOCATION` environment variable to container to spe
|
|
106
106
|
docker run --link xray:xray --env AWS_XRAY_LOCATION=xray:2000 my-application
|
107
107
|
```
|
108
108
|
|
109
|
-
###
|
109
|
+
### Excluded paths
|
110
|
+
To avoid tracing health checking requests, use "excluded paths" configuration.
|
111
|
+
|
112
|
+
- Environment variable: `AWS_XRAY_EXCLUDED_PATHS=/health_check,/another_check`
|
113
|
+
- Global configuration: `Aws::Xray.config.excluded_paths = %w[/health_check /another_check]`
|
114
|
+
|
115
|
+
### Recording application version
|
110
116
|
aws-xray automatically tries to set application version by reading `app_root/REVISION` file.
|
111
117
|
If you want to set another version, set it with:
|
112
118
|
|
data/aws-xray.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'faraday'
|
25
25
|
spec.add_development_dependency 'bundler'
|
26
26
|
spec.add_development_dependency 'rake'
|
27
|
+
spec.add_development_dependency 'rack-test'
|
27
28
|
spec.add_development_dependency 'rspec'
|
28
29
|
spec.add_development_dependency 'pry-byebug'
|
29
30
|
end
|
@@ -9,8 +9,17 @@ module Aws
|
|
9
9
|
DEFAULT_HOST = option ? option.split(':').first : 'localhost'
|
10
10
|
DEFAULT_PORT = option ? Integer(option.split(':').last) : 2000
|
11
11
|
|
12
|
+
name_option = ENV['AWS_XRAY_NAME']
|
13
|
+
DEFAULT_NAME = name_option ? name_option : nil
|
14
|
+
|
15
|
+
path_option = ENV['AWS_XRAY_EXCLUDED_PATHS']
|
16
|
+
DEFAULT_EXCLUDED_PATHS = path_option ? path_option.split(',') : []
|
17
|
+
|
12
18
|
# @return [String] name Logical service name for this application.
|
13
|
-
|
19
|
+
def name
|
20
|
+
@name ||= DEFAULT_NAME
|
21
|
+
end
|
22
|
+
attr_writer :name
|
14
23
|
|
15
24
|
# @return [Hash] client_options For xray-agent client.
|
16
25
|
# - host: e.g. '127.0.0.1'
|
@@ -21,6 +30,12 @@ module Aws
|
|
21
30
|
end
|
22
31
|
attr_writer :client_options
|
23
32
|
|
33
|
+
# @return [Array<String>]
|
34
|
+
def excluded_paths
|
35
|
+
@excluded_paths ||= DEFAULT_EXCLUDED_PATHS
|
36
|
+
end
|
37
|
+
attr_writer :excluded_paths
|
38
|
+
|
24
39
|
# @return [String]
|
25
40
|
def version
|
26
41
|
@version ||= VersionDetector.new.call
|
data/lib/aws/xray/rack.rb
CHANGED
@@ -8,19 +8,29 @@ module Aws
|
|
8
8
|
class Rack
|
9
9
|
TRACE_ENV = 'HTTP_X_AMZN_TRACE_ID'.freeze
|
10
10
|
|
11
|
-
# TODO: excluded_paths, included_paths
|
12
|
-
#
|
13
11
|
# @param [Hash] client_options For xray-agent client.
|
14
12
|
# - host: e.g. '127.0.0.1'
|
15
13
|
# - port: e.g. 2000
|
16
14
|
# - sock: test purpose.
|
17
|
-
|
15
|
+
# @param [Array<String>] excluded_paths for health-check endpoints etc...
|
16
|
+
def initialize(app, client_options: {}, excluded_paths: [])
|
18
17
|
@app = app
|
19
18
|
@name = Aws::Xray.config.name || raise(MissingNameError)
|
20
19
|
@client = Client.new(Aws::Xray.config.client_options.merge(client_options))
|
20
|
+
@excluded_paths = excluded_paths + Aws::Xray.config.excluded_paths
|
21
21
|
end
|
22
22
|
|
23
23
|
def call(env)
|
24
|
+
if @excluded_paths.include?(env['PATH_INFO'])
|
25
|
+
@app.call(env)
|
26
|
+
else
|
27
|
+
call_with_tracing(env)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def call_with_tracing(env)
|
24
34
|
header_value = env[TRACE_ENV]
|
25
35
|
trace = if header_value
|
26
36
|
Trace.build_from_header_value(header_value)
|
data/lib/aws/xray/rails.rb
CHANGED
@@ -4,7 +4,15 @@ module Aws
|
|
4
4
|
module Xray
|
5
5
|
class Railtie < ::Rails::Railtie
|
6
6
|
initializer 'aws-xray.set_name' do |app|
|
7
|
-
Aws::Xray.config.name
|
7
|
+
unless Aws::Xray.config.name
|
8
|
+
app_name = app.class.parent_name.underscore.gsub(/(\/|_)/, '-')
|
9
|
+
|
10
|
+
if Rails.env.production?
|
11
|
+
Aws::Xray.config.name = app_name
|
12
|
+
else
|
13
|
+
Aws::Xray.config.name = "#{app_name}-#{Rails.env}"
|
14
|
+
end
|
15
|
+
end
|
8
16
|
end
|
9
17
|
|
10
18
|
initializer 'aws-xray.rack_middleware' do |app|
|
data/lib/aws/xray/segment.rb
CHANGED
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taiki Ono
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack-test
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|