zipkin 1.1.0 → 1.2.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/.rubocop.yml +6 -0
- data/lib/zipkin/collector.rb +6 -3
- data/lib/zipkin/collector/log_annotations.rb +26 -0
- data/lib/zipkin/collector/timestamp.rb +9 -0
- data/lib/zipkin/span.rb +5 -7
- data/script/create_trace +2 -0
- data/zipkin.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 253ec789b0311c2a35709b958e1f5fd3e026b043
|
4
|
+
data.tar.gz: 0367fc35f6be4d5da713bc72bddd425ee0fefca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a2a52800b14c3976e9e8ca384fc697fc153d6f1ded256fc698ae22c39d7f2bf991400c518440286c72836743b6db6f42b707e2ba20e364c1a3bb0e7ab7b6da6
|
7
|
+
data.tar.gz: 5c2afbb1f91211202b65b4be3f0ca5a228a0180669a442d376a527c63d62a008d9a776cdbc085013068331ba6de4fc9425d51bfeaf9efd1d16c6080b4751fea7
|
data/.rubocop.yml
CHANGED
data/lib/zipkin/collector.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'thread'
|
2
2
|
|
3
|
+
require_relative './collector/timestamp'
|
4
|
+
require_relative './collector/log_annotations'
|
5
|
+
|
3
6
|
module Zipkin
|
4
7
|
class Collector
|
5
8
|
def initialize(local_endpoint)
|
@@ -12,8 +15,8 @@ module Zipkin
|
|
12
15
|
end
|
13
16
|
|
14
17
|
def send_span(span, end_time)
|
15
|
-
finish_ts = (end_time
|
16
|
-
start_ts = (span.start_time
|
18
|
+
finish_ts = Timestamp.create(end_time)
|
19
|
+
start_ts = Timestamp.create(span.start_time)
|
17
20
|
duration = finish_ts - start_ts
|
18
21
|
is_server = %w[server consumer].include?(span.tags['span.kind'] || 'server')
|
19
22
|
|
@@ -24,7 +27,7 @@ module Zipkin
|
|
24
27
|
name: span.operation_name,
|
25
28
|
timestamp: start_ts,
|
26
29
|
duration: duration,
|
27
|
-
annotations: [
|
30
|
+
annotations: LogAnnotations.build(span, @local_endpoint) + [
|
28
31
|
{
|
29
32
|
timestamp: start_ts,
|
30
33
|
value: is_server ? 'sr' : 'cs',
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Zipkin
|
2
|
+
class Collector
|
3
|
+
module LogAnnotations
|
4
|
+
def self.build(span, endpoint)
|
5
|
+
span.logs.map do |log|
|
6
|
+
{
|
7
|
+
timestamp: Timestamp.create(log.fetch(:timestamp)),
|
8
|
+
value: format_log_value(log),
|
9
|
+
endpoint: endpoint
|
10
|
+
}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.format_log_value(log)
|
15
|
+
if log.keys == %i[event timestamp]
|
16
|
+
log.fetch(:event)
|
17
|
+
else
|
18
|
+
log
|
19
|
+
.reject { |key, _value| key == :timestamp }
|
20
|
+
.map { |key, value| "#{key}=#{value}" }
|
21
|
+
.join(' ')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/zipkin/span.rb
CHANGED
@@ -2,7 +2,7 @@ module Zipkin
|
|
2
2
|
class Span
|
3
3
|
attr_accessor :operation_name
|
4
4
|
|
5
|
-
attr_reader :context, :start_time, :tags
|
5
|
+
attr_reader :context, :start_time, :tags, :logs
|
6
6
|
|
7
7
|
# Creates a new {Span}
|
8
8
|
#
|
@@ -17,6 +17,7 @@ module Zipkin
|
|
17
17
|
@collector = collector
|
18
18
|
@start_time = start_time
|
19
19
|
@tags = tags
|
20
|
+
@logs = []
|
20
21
|
end
|
21
22
|
|
22
23
|
# Set a tag value on this span
|
@@ -47,14 +48,10 @@ module Zipkin
|
|
47
48
|
|
48
49
|
# Add a log entry to this span
|
49
50
|
#
|
50
|
-
# @param event [String] event name for the log
|
51
|
-
# @param timestamp [Time] time of the log
|
52
|
-
# @param fields [Hash] Additional information to log
|
53
|
-
#
|
54
51
|
# @deprecated Use {#log_kv} instead.
|
55
|
-
def log(
|
52
|
+
def log(*args)
|
56
53
|
warn 'Span#log is deprecated. Please use Span#log_kv instead.'
|
57
|
-
|
54
|
+
log_kv(*args)
|
58
55
|
end
|
59
56
|
|
60
57
|
# Add a log entry to this span
|
@@ -62,6 +59,7 @@ module Zipkin
|
|
62
59
|
# @param timestamp [Time] time of the log
|
63
60
|
# @param fields [Hash] Additional information to log
|
64
61
|
def log_kv(timestamp: Time.now, **fields)
|
62
|
+
@logs << fields.merge(timestamp: timestamp)
|
65
63
|
nil
|
66
64
|
end
|
67
65
|
|
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.2.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-04-
|
11
|
+
date: 2018-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,6 +128,8 @@ files:
|
|
128
128
|
- lib/zipkin.rb
|
129
129
|
- lib/zipkin/carrier.rb
|
130
130
|
- lib/zipkin/collector.rb
|
131
|
+
- lib/zipkin/collector/log_annotations.rb
|
132
|
+
- lib/zipkin/collector/timestamp.rb
|
131
133
|
- lib/zipkin/endpoint.rb
|
132
134
|
- lib/zipkin/json_client.rb
|
133
135
|
- lib/zipkin/span.rb
|