zipkin-tracer 0.26.0 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05f65d2bb130fb08a93c2d8f0a9e0f37af0e880e
|
4
|
+
data.tar.gz: 4a2367d64760ae201df8b38bc372812b87779236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36a3443425732fbe0d0cb61f03530f7ebd0876931097a814a164610b55adad24fa4b26071f55abcd78d68341afc414665c334798e3b80891ae07bcf9acb0775e
|
7
|
+
data.tar.gz: 02453b03c11987c52d8192034d2864e462e9961c9f390e2754c78fd2fd875bcbc68e9e5937265483cab4ac19b43f4832e70667e3573a3e5f18a9dbb4f44540c5
|
@@ -29,13 +29,9 @@ module ZipkinTracer
|
|
29
29
|
|
30
30
|
def response_call(datum)
|
31
31
|
if span = datum[:span]
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
status,
|
36
|
-
Trace::BinaryAnnotation::Type::STRING,
|
37
|
-
local_endpoint
|
38
|
-
)
|
32
|
+
status = response_status(datum)
|
33
|
+
if status
|
34
|
+
record_response_tags(span, status, local_endpoint)
|
39
35
|
end
|
40
36
|
span.record(Trace::Annotation::CLIENT_RECV, local_endpoint)
|
41
37
|
Trace.tracer.end_span(span)
|
@@ -47,6 +43,7 @@ module ZipkinTracer
|
|
47
43
|
private
|
48
44
|
|
49
45
|
SERVER_ADDRESS_SPECIAL_VALUE = '1'.freeze
|
46
|
+
STATUS_ERROR_REGEXP = /\A(4.*|5.*)\z/.freeze
|
50
47
|
|
51
48
|
def b3_headers
|
52
49
|
{
|
@@ -74,6 +71,14 @@ module ZipkinTracer
|
|
74
71
|
datum[:response] && datum[:response][:status] && datum[:response][:status].to_s
|
75
72
|
end
|
76
73
|
|
74
|
+
def record_response_tags(span, status, local_endpoint)
|
75
|
+
span.record_tag(Trace::BinaryAnnotation::STATUS, status, Trace::BinaryAnnotation::Type::STRING, local_endpoint)
|
76
|
+
if STATUS_ERROR_REGEXP.match(status)
|
77
|
+
span.record_tag(Trace::BinaryAnnotation::ERROR, status,
|
78
|
+
Trace::BinaryAnnotation::Type::STRING, local_endpoint)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
77
82
|
def trace!(datum, trace_id)
|
78
83
|
url_string = Excon::Utils::request_uri(datum)
|
79
84
|
url = URI(url_string)
|
@@ -28,6 +28,8 @@ module ZipkinTracer
|
|
28
28
|
private
|
29
29
|
|
30
30
|
SERVER_ADDRESS_SPECIAL_VALUE = '1'.freeze
|
31
|
+
STATUS_ERROR_REGEXP = /\A(4.*|5.*)\z/.freeze
|
32
|
+
|
31
33
|
|
32
34
|
def b3_headers
|
33
35
|
{
|
@@ -46,17 +48,38 @@ module ZipkinTracer
|
|
46
48
|
local_endpoint = Trace.default_endpoint # The rack middleware set this up for us.
|
47
49
|
remote_endpoint = Trace::Endpoint.remote_endpoint(url, @service_name, local_endpoint.ip_format) # The endpoint we are calling.
|
48
50
|
Trace.tracer.with_new_span(trace_id, env[:method].to_s.downcase) do |span|
|
51
|
+
@span = span # So we can record on exceptions
|
49
52
|
# annotate with method (GET/POST/etc.) and uri path
|
50
53
|
span.record_tag(Trace::BinaryAnnotation::PATH, url.path, Trace::BinaryAnnotation::Type::STRING, local_endpoint)
|
51
54
|
span.record_tag(Trace::BinaryAnnotation::SERVER_ADDRESS, SERVER_ADDRESS_SPECIAL_VALUE, Trace::BinaryAnnotation::Type::BOOL, remote_endpoint)
|
52
55
|
span.record(Trace::Annotation::CLIENT_SEND, local_endpoint)
|
53
56
|
response = @app.call(env).on_complete do |renv|
|
54
|
-
|
55
|
-
span.record_tag(Trace::BinaryAnnotation::STATUS, renv[:status].to_s, Trace::BinaryAnnotation::Type::STRING, local_endpoint)
|
57
|
+
record_response_tags(span, renv[:status].to_s, local_endpoint)
|
56
58
|
end
|
57
59
|
span.record(Trace::Annotation::CLIENT_RECV, local_endpoint)
|
58
60
|
end
|
59
61
|
response
|
62
|
+
rescue Net::ReadTimeout
|
63
|
+
record_error(@span, 'Request timed out.', local_endpoint)
|
64
|
+
raise
|
65
|
+
rescue Faraday::ConnectionFailed
|
66
|
+
record_error(@span, 'Request connection failed.', local_endpoint)
|
67
|
+
raise
|
68
|
+
rescue Faraday::ClientError
|
69
|
+
record_error(@span, 'Generic Faraday client error.', local_endpoint)
|
70
|
+
raise
|
71
|
+
end
|
72
|
+
|
73
|
+
def record_error(span, msg, local_endpoint)
|
74
|
+
span.record_tag(Trace::BinaryAnnotation::ERROR, msg, Trace::BinaryAnnotation::Type::STRING, local_endpoint)
|
75
|
+
end
|
76
|
+
|
77
|
+
def record_response_tags(span, status, local_endpoint)
|
78
|
+
span.record_tag(Trace::BinaryAnnotation::STATUS, status, Trace::BinaryAnnotation::Type::STRING, local_endpoint)
|
79
|
+
if STATUS_ERROR_REGEXP.match(status)
|
80
|
+
span.record_tag(Trace::BinaryAnnotation::ERROR, status,
|
81
|
+
Trace::BinaryAnnotation::Type::STRING, local_endpoint)
|
82
|
+
end
|
60
83
|
end
|
61
84
|
|
62
85
|
end
|
data/lib/zipkin-tracer/trace.rb
CHANGED