aws-xray 0.8.1 → 0.9.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/lib/aws/xray/annotation_normalizer.rb +37 -0
- data/lib/aws/xray/configuration.rb +2 -3
- data/lib/aws/xray/segment.rb +2 -3
- data/lib/aws/xray/version.rb +1 -1
- metadata +3 -3
- data/lib/aws/xray/annotation_validator.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b263ae80bfea7fa1cee9f95c26d5ca57dd136098
|
4
|
+
data.tar.gz: ce94410321f8fa5a3b29219d6e17f12b0f004e36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45715f823e2b871f17826b85e37cf7e02885de7669423bacbf33d17fc227db01de3807c81cc3c932ea1bb6770621637587bf4150ef8736cd4f44bc5fdbaf919a
|
7
|
+
data.tar.gz: dba1945e5aa2130fb1a1add974475407ec492bafaeda31a885de9e50da21cae022774a4bc249bd61d33528bb8321c8321690fd7c07c983555ea0d0d3839a92f3
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Aws
|
2
|
+
module Xray
|
3
|
+
# For specification: http://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html
|
4
|
+
module AnnotationNormalizer
|
5
|
+
extend self
|
6
|
+
|
7
|
+
# @param [Hash] h annotation hash.
|
8
|
+
# @return [Hash]
|
9
|
+
def call(h)
|
10
|
+
h.inject({}) {|init, (k, v)| init[normalize_key(k)] = normalize_value(v); init }
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
INVALID_PATTERN = /[^A-Za-z0-9_]+/
|
16
|
+
# - Convert keys which including '-' to '_'
|
17
|
+
# because it might be common pit-fall.
|
18
|
+
# - Remove invalid chars.
|
19
|
+
def normalize_key(k)
|
20
|
+
k.to_s.gsub('-', '_').gsub(INVALID_PATTERN, '').to_sym
|
21
|
+
end
|
22
|
+
|
23
|
+
def normalize_value(v)
|
24
|
+
case v
|
25
|
+
when nil
|
26
|
+
nil
|
27
|
+
when Integer, Float
|
28
|
+
v
|
29
|
+
when true, false
|
30
|
+
v
|
31
|
+
else
|
32
|
+
v.to_s
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'socket'
|
2
|
-
require 'aws/xray/
|
2
|
+
require 'aws/xray/annotation_normalizer'
|
3
3
|
|
4
4
|
module Aws
|
5
5
|
module Xray
|
@@ -59,8 +59,7 @@ module Aws
|
|
59
59
|
end
|
60
60
|
# @param [Hash] h default annotation Hash.
|
61
61
|
def default_annotation=(annotation)
|
62
|
-
|
63
|
-
@default_annotation = annotation
|
62
|
+
@default_annotation = AnnotationNormalizer.call(annotation)
|
64
63
|
end
|
65
64
|
|
66
65
|
DEFAULT_METADATA = {
|
data/lib/aws/xray/segment.rb
CHANGED
@@ -3,7 +3,7 @@ require 'securerandom'
|
|
3
3
|
require 'aws/xray/request'
|
4
4
|
require 'aws/xray/response'
|
5
5
|
require 'aws/xray/error'
|
6
|
-
require 'aws/xray/
|
6
|
+
require 'aws/xray/annotation_normalizer'
|
7
7
|
|
8
8
|
module Aws
|
9
9
|
module Xray
|
@@ -55,8 +55,7 @@ module Aws
|
|
55
55
|
# @param [Hash] annotation Keys must consist of only alphabets and underscore.
|
56
56
|
# Values must be one of String or Integer or Boolean values.
|
57
57
|
def set_annotation(annotation)
|
58
|
-
|
59
|
-
@annotation = @annotation.merge(annotation)
|
58
|
+
@annotation = @annotation.merge(AnnotationNormalizer.call(annotation))
|
60
59
|
end
|
61
60
|
|
62
61
|
# @param [Hash] metadata
|
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.9.0
|
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-
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -122,7 +122,7 @@ files:
|
|
122
122
|
- example/user_app_config.ru
|
123
123
|
- lib/aws-xray.rb
|
124
124
|
- lib/aws/xray.rb
|
125
|
-
- lib/aws/xray/
|
125
|
+
- lib/aws/xray/annotation_normalizer.rb
|
126
126
|
- lib/aws/xray/cause.rb
|
127
127
|
- lib/aws/xray/client.rb
|
128
128
|
- lib/aws/xray/configuration.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Aws
|
2
|
-
module Xray
|
3
|
-
module AnnotationValidator
|
4
|
-
extend self
|
5
|
-
|
6
|
-
# @param [Hash] h annotation hash.
|
7
|
-
# @raise RuntimeError
|
8
|
-
def call(h)
|
9
|
-
invalid_keys = h.keys.reject {|k| k.to_s.match(/\A[A-Za-z0-9_]+\z/) }
|
10
|
-
raise 'Keys must be alphanumeric and underscore string' unless invalid_keys.empty?
|
11
|
-
invalid_values = h.values.reject {|v| v.is_a?(String) || v.is_a?(Integer) || (v == true || v == false) }
|
12
|
-
raise 'Values must be one of String or Integer or Boolean values' unless invalid_values.empty?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|