zipkin-tracer 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmY0OTE5MGZkYzk3ZDhjNjUyMzk0MjA4MWNkZDhjMWZjNDQxNDMyMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTlhNjFhYzc5Nzg0NDVhMDMwMTRiY2MzNDcxMzVjOGM2NDVjNGM2YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDZiNDI1OTRhNzYyYmFiZWMwNmYwZWM3MzdlOGVjNDVlMDU3OWVlMzg4MGY1
|
10
|
+
ZWVmMzQwZDFiMzkwMGY1YzY3Yzg4NzI4YmFlMWEyNjg0OWQyNjU4NTgzODNh
|
11
|
+
YWNhN2NjZjMzMTMwZjI0NzYzYTYxNjgxMTNmODNmYjhkZDAzNWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmZkMjYxNDRiMTY0N2Y0NDRhOTMxNjZiYWNjMjFhMTY1MGJiMjVhZDdiNDI0
|
14
|
+
MGNiMjFiNTI1M2Q1YzU1NjhhZTE5YWVlZDBjZTg3MWNiMDc4OGM4YjdlZTVi
|
15
|
+
Y2NhN2VjYmMzNDE1MTM5OTljOTgxNDAxNGQ0ZTlhNWM1YWFhODc=
|
@@ -35,12 +35,7 @@ module ZipkinTracer
|
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
38
|
-
SERVER_ADDRESS = 'sa'.freeze
|
39
38
|
SERVER_ADDRESS_SPECIAL_VALUE = '1'.freeze
|
40
|
-
STRING_TYPE = 'STRING'.freeze
|
41
|
-
BOOLEAN_TYPE = 'BOOL'.freeze
|
42
|
-
URI_KEY = 'http.uri'.freeze
|
43
|
-
STATUS_KEY = 'http.status'.freeze
|
44
39
|
|
45
40
|
def trace!(env, trace_id)
|
46
41
|
response = nil
|
@@ -50,14 +45,14 @@ module ZipkinTracer
|
|
50
45
|
remote_endpoint = Trace::Endpoint.remote_endpoint(url, @service_name, local_endpoint.ip_format) # The endpoint we are calling.
|
51
46
|
@tracer.with_new_span(trace_id, env[:method].to_s.downcase) do |span|
|
52
47
|
# annotate with method (GET/POST/etc.) and uri path
|
53
|
-
span.
|
54
|
-
span.
|
55
|
-
span.record(Trace::Annotation
|
48
|
+
span.record_tag(Trace::BinaryAnnotation::URI, url.path, Trace::BinaryAnnotation::Type::STRING, local_endpoint)
|
49
|
+
span.record_tag(Trace::BinaryAnnotation::SERVER_ADDRESS, SERVER_ADDRESS_SPECIAL_VALUE, Trace::BinaryAnnotation::Type::BOOL, remote_endpoint)
|
50
|
+
span.record(Trace::Annotation::CLIENT_SEND, local_endpoint)
|
56
51
|
response = @app.call(env).on_complete do |renv|
|
57
52
|
# record HTTP status code on response
|
58
|
-
span.
|
53
|
+
span.record_tag(Trace::BinaryAnnotation::STATUS, renv[:status].to_s, Trace::BinaryAnnotation::Type::STRING, local_endpoint)
|
59
54
|
end
|
60
|
-
span.record(Trace::Annotation
|
55
|
+
span.record(Trace::Annotation::CLIENT_RECV, local_endpoint)
|
61
56
|
end
|
62
57
|
response
|
63
58
|
end
|
@@ -55,19 +55,19 @@ module ZipkinTracer
|
|
55
55
|
synchronize do
|
56
56
|
#if called by a service, the caller already added the information
|
57
57
|
trace_request_information(span, zipkin_env.env) unless zipkin_env.called_with_zipkin_headers?
|
58
|
-
span.record(Trace::Annotation
|
59
|
-
span.record(
|
58
|
+
span.record(Trace::Annotation::SERVER_RECV)
|
59
|
+
span.record('whitelisted') if zipkin_env.force_sample?
|
60
60
|
end
|
61
61
|
status, headers, body = yield
|
62
62
|
ensure
|
63
63
|
synchronize do
|
64
64
|
annotate_plugin(zipkin_env.env, status, headers, body)
|
65
|
-
span.record(Trace::Annotation
|
65
|
+
span.record(Trace::Annotation::SERVER_SEND)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
def trace_request_information(span, env)
|
70
|
-
span.
|
70
|
+
span.record_tag(Trace::BinaryAnnotation::URI, env['PATH_INFO'])
|
71
71
|
end
|
72
72
|
|
73
73
|
def synchronize(&block)
|
data/lib/zipkin-tracer/trace.rb
CHANGED
@@ -32,16 +32,6 @@ module Trace
|
|
32
32
|
@duration = to_microseconds(Time.now) - @timestamp
|
33
33
|
end
|
34
34
|
|
35
|
-
# We record information into spans, then we send these spans to zipkin
|
36
|
-
def record(annotation)
|
37
|
-
case annotation
|
38
|
-
when BinaryAnnotation
|
39
|
-
binary_annotations << annotation
|
40
|
-
when Annotation
|
41
|
-
annotations << annotation
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
35
|
def to_h
|
46
36
|
{
|
47
37
|
name: @name,
|
@@ -56,6 +46,19 @@ module Trace
|
|
56
46
|
}
|
57
47
|
end
|
58
48
|
|
49
|
+
# We record information into spans, then we send these spans to zipkin
|
50
|
+
def record(value, endpoint = Trace.default_endpoint)
|
51
|
+
annotations << Trace::Annotation.new(value, endpoint)
|
52
|
+
end
|
53
|
+
|
54
|
+
def record_tag(key, value, type = Trace::BinaryAnnotation::Type::STRING, endpoint = Trace.default_endpoint)
|
55
|
+
binary_annotations << Trace::BinaryAnnotation.new(key, value, type, endpoint)
|
56
|
+
end
|
57
|
+
|
58
|
+
def record_local_component(value)
|
59
|
+
record_tag(BinaryAnnotation::LOCAL_COMPONENT, value)
|
60
|
+
end
|
61
|
+
|
59
62
|
private
|
60
63
|
|
61
64
|
UNKNOWN_DURATION = 0 # mark duration was not set
|
@@ -78,6 +81,11 @@ module Trace
|
|
78
81
|
|
79
82
|
# This class is defined in finagle-thrift. We are adding extra methods here
|
80
83
|
class BinaryAnnotation
|
84
|
+
SERVER_ADDRESS = 'sa'.freeze
|
85
|
+
URI = 'http.uri'.freeze
|
86
|
+
STATUS = 'http.status'.freeze
|
87
|
+
LOCAL_COMPONENT = 'lc'.freeze
|
88
|
+
|
81
89
|
def to_h
|
82
90
|
{
|
83
91
|
key: @key,
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module ZipkinTracer
|
2
|
-
class
|
3
|
-
|
4
|
-
|
2
|
+
class NullSpan
|
3
|
+
def method_missing(name, *args)
|
4
|
+
end
|
5
|
+
end
|
5
6
|
|
7
|
+
class TraceClient
|
6
8
|
def self.local_component_span(local_component_value, &block)
|
7
9
|
client = self.new
|
8
10
|
client.trace(local_component_value, &block)
|
@@ -13,27 +15,18 @@ module ZipkinTracer
|
|
13
15
|
|
14
16
|
@trace_id = Trace.id.next_id
|
15
17
|
result = nil
|
16
|
-
|
17
|
-
Trace.
|
18
|
-
@
|
19
|
-
|
20
|
-
|
18
|
+
if @trace_id.sampled?
|
19
|
+
Trace.with_trace_id(@trace_id) do
|
20
|
+
Trace.tracer.with_new_span(@trace_id, Trace::BinaryAnnotation::LOCAL_COMPONENT) do |span|
|
21
|
+
result = block.call(span)
|
22
|
+
span.record_local_component local_component_value
|
23
|
+
end
|
21
24
|
end
|
25
|
+
else
|
26
|
+
result = block.call(NullSpan.new)
|
22
27
|
end
|
23
28
|
result
|
24
29
|
end
|
25
30
|
|
26
|
-
def record(key)
|
27
|
-
@span.record(Trace::Annotation.new(key, Trace.default_endpoint)) if @trace_id.sampled?
|
28
|
-
end
|
29
|
-
|
30
|
-
def record_tag(key, value)
|
31
|
-
@span.record(Trace::BinaryAnnotation.new(key, value, STRING_TYPE, Trace.default_endpoint)) if @trace_id.sampled?
|
32
|
-
end
|
33
|
-
|
34
|
-
def record_local_component(value)
|
35
|
-
record_tag(LOCAL_COMPONENT, value)
|
36
|
-
end
|
37
|
-
|
38
31
|
end
|
39
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zipkin-tracer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franklin Hu
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2016-02-
|
16
|
+
date: 2016-02-08 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: faraday
|