zipkin 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/zipkin/collector.rb +9 -18
- data/lib/zipkin/collector/log_annotations.rb +2 -3
- data/lib/zipkin/endpoint.rb +42 -0
- data/lib/zipkin/json_client.rb +1 -1
- data/lib/zipkin/span_context.rb +11 -0
- data/script/create_trace +3 -1
- data/zipkin.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4226e47ea8224eeffa7ed8cd4e48e61cc26da790
|
4
|
+
data.tar.gz: f7ab917023ea03c1660d3f218b1e6f56147da8be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ad6f2ce25802dfd4fca0191a52ef6653887894571f2571663c6ccfa559a9f7241581acd7ceae158040e8056cf95c4016db83883b880077956e45caee9fca109
|
7
|
+
data.tar.gz: 5165e5c4d02358d9a8a996baa398450975fb04d542e961464730cb1c58ec287fcf2a66676a1661311f4b4190f50d52f2f0df0dc6b4933fcab0642d79ab777132
|
data/README.md
CHANGED
data/lib/zipkin/collector.rb
CHANGED
@@ -18,37 +18,28 @@ module Zipkin
|
|
18
18
|
finish_ts = Timestamp.create(end_time)
|
19
19
|
start_ts = Timestamp.create(span.start_time)
|
20
20
|
duration = finish_ts - start_ts
|
21
|
-
is_server = %w[server consumer].include?(span.tags['span.kind'] || 'server')
|
22
21
|
|
23
22
|
@buffer << {
|
24
23
|
traceId: span.context.trace_id,
|
25
24
|
id: span.context.span_id,
|
26
25
|
parentId: span.context.parent_id,
|
27
26
|
name: span.operation_name,
|
27
|
+
kind: (span.tags['span.kind'] || 'SERVER').upcase,
|
28
28
|
timestamp: start_ts,
|
29
29
|
duration: duration,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
{
|
37
|
-
timestamp: finish_ts,
|
38
|
-
value: is_server ? 'ss' : 'cr',
|
39
|
-
endpoint: @local_endpoint
|
40
|
-
}
|
41
|
-
],
|
42
|
-
binaryAnnotations: build_binary_annotations(span)
|
30
|
+
debug: false,
|
31
|
+
shared: false,
|
32
|
+
localEndpoint: @local_endpoint,
|
33
|
+
remoteEndpoint: Endpoint.remote_endpoint(span),
|
34
|
+
annotations: LogAnnotations.build(span),
|
35
|
+
tags: build_tags(span)
|
43
36
|
}
|
44
37
|
end
|
45
38
|
|
46
39
|
private
|
47
40
|
|
48
|
-
def
|
49
|
-
span.tags.map
|
50
|
-
{ key: name, value: value.to_s }
|
51
|
-
end
|
41
|
+
def build_tags(span)
|
42
|
+
span.tags.map { |key, value| [key.to_s, value.to_s] }.to_h
|
52
43
|
end
|
53
44
|
|
54
45
|
class Buffer
|
@@ -1,12 +1,11 @@
|
|
1
1
|
module Zipkin
|
2
2
|
class Collector
|
3
3
|
module LogAnnotations
|
4
|
-
def self.build(span
|
4
|
+
def self.build(span)
|
5
5
|
span.logs.map do |log|
|
6
6
|
{
|
7
7
|
timestamp: Timestamp.create(log.fetch(:timestamp)),
|
8
|
-
value: format_log_value(log)
|
9
|
-
endpoint: endpoint
|
8
|
+
value: format_log_value(log)
|
10
9
|
}
|
11
10
|
end
|
12
11
|
end
|
data/lib/zipkin/endpoint.rb
CHANGED
@@ -7,11 +7,53 @@ module Zipkin
|
|
7
7
|
Socket.ip_address_list.reverse.detect(&:ipv4?)
|
8
8
|
).ip_address
|
9
9
|
|
10
|
+
module SpanKind
|
11
|
+
SERVER = 'server'.freeze
|
12
|
+
CLIENT = 'client'.freeze
|
13
|
+
PRODUCER = 'producer'.freeze
|
14
|
+
CONSUMER = 'consumer'.freeze
|
15
|
+
end
|
16
|
+
|
17
|
+
module PeerInfo
|
18
|
+
SERVICE = 'peer.service'.freeze
|
19
|
+
IPV4 = 'peer.ipv4'.freeze
|
20
|
+
IPV6 = 'peer.ipv6'.freeze
|
21
|
+
PORT = 'peer.port'.freeze
|
22
|
+
|
23
|
+
def self.keys
|
24
|
+
[SERVICE, IPV4, IPV6, PORT]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
10
28
|
def self.local_endpoint(service_name)
|
11
29
|
{
|
12
30
|
serviceName: service_name,
|
13
31
|
ipv4: LOCAL_IP
|
14
32
|
}
|
15
33
|
end
|
34
|
+
|
35
|
+
def self.remote_endpoint(span)
|
36
|
+
tags = span.tags
|
37
|
+
kind = tags['span.kind'] || SpanKind::SERVER
|
38
|
+
|
39
|
+
case kind
|
40
|
+
when SpanKind::SERVER, SpanKind::CLIENT
|
41
|
+
return nil if (tags.keys & PeerInfo.keys).empty?
|
42
|
+
|
43
|
+
{
|
44
|
+
serviceName: tags[PeerInfo::SERVICE],
|
45
|
+
ipv4: tags[PeerInfo::IPV4],
|
46
|
+
ipv6: tags[PeerInfo::IPV6],
|
47
|
+
port: tags[PeerInfo::PORT]
|
48
|
+
}
|
49
|
+
when SpanKind::PRODUCER, SpanKind::CONSUMER
|
50
|
+
{
|
51
|
+
serviceName: 'broker'
|
52
|
+
}
|
53
|
+
else
|
54
|
+
warn "Unkown span kind: #{kind}"
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
end
|
16
58
|
end
|
17
59
|
end
|
data/lib/zipkin/json_client.rb
CHANGED
@@ -7,7 +7,7 @@ module Zipkin
|
|
7
7
|
def initialize(url:, collector:, flush_interval:, logger: Logger.new(STDOUT))
|
8
8
|
@collector = collector
|
9
9
|
@flush_interval = flush_interval
|
10
|
-
@spans_uri = URI.parse("#{url}/api/
|
10
|
+
@spans_uri = URI.parse("#{url}/api/v2/spans")
|
11
11
|
@logger = logger
|
12
12
|
end
|
13
13
|
|
data/lib/zipkin/span_context.rb
CHANGED
@@ -28,5 +28,16 @@ module Zipkin
|
|
28
28
|
def sampled?
|
29
29
|
@sampled
|
30
30
|
end
|
31
|
+
|
32
|
+
# NOTE: This method is not defined in OpenTracing Ruby spec. Use with
|
33
|
+
# caution.
|
34
|
+
def to_h
|
35
|
+
{
|
36
|
+
span_id: @span_id,
|
37
|
+
parent_id: @parent_id,
|
38
|
+
trace_id: @trace_id,
|
39
|
+
sampled: @sampled
|
40
|
+
}
|
41
|
+
end
|
31
42
|
end
|
32
43
|
end
|
data/script/create_trace
CHANGED
data/zipkin.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zipkin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SaleMove TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|