zipkin 1.1.0 → 1.2.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: f7dab2beecf1b862caceca696f39c800ed9a337a
4
- data.tar.gz: d5047d7b504e42a2d4357f991e651e9dc70fd9f3
3
+ metadata.gz: 253ec789b0311c2a35709b958e1f5fd3e026b043
4
+ data.tar.gz: 0367fc35f6be4d5da713bc72bddd425ee0fefca4
5
5
  SHA512:
6
- metadata.gz: 42534373a551f427b6be03b32ca2709e7fae389b36a9d93c224ab7e3b4b1db04459a2ad5046a12dcf5e1cf7d3a3e0dbb8c2fbc8d61d72d9d2181cf61a7011e16
7
- data.tar.gz: cd4a6a54266e0972a6ab0af9314bb929de8624bb9af13db6f2a25d433ad4cb89d1c282c0aed41378fa89b6a27c763508c3b49763376302df5d8792ce3203cedd
6
+ metadata.gz: 3a2a52800b14c3976e9e8ca384fc697fc153d6f1ded256fc698ae22c39d7f2bf991400c518440286c72836743b6db6f42b707e2ba20e364c1a3bb0e7ab7b6da6
7
+ data.tar.gz: 5c2afbb1f91211202b65b4be3f0ca5a228a0180669a442d376a527c63d62a008d9a776cdbc085013068331ba6de4fc9425d51bfeaf9efd1d16c6080b4751fea7
data/.rubocop.yml CHANGED
@@ -9,6 +9,12 @@ Style/IfUnlessModifier:
9
9
  RSpec/NestedGroups:
10
10
  Max: 4
11
11
 
12
+ RSpec/ExampleLength:
13
+ Enabled: no
14
+
15
+ RSpec/MultipleExpectations:
16
+ Enabled: no
17
+
12
18
  Metrics/BlockLength:
13
19
  Enabled: no
14
20
 
@@ -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.to_f * 1_000_000).to_i
16
- start_ts = (span.start_time.to_f * 1_000_000).to_i
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
@@ -0,0 +1,9 @@
1
+ module Zipkin
2
+ class Collector
3
+ module Timestamp
4
+ def self.create(time)
5
+ (time.to_f * 1_000_000).to_i
6
+ end
7
+ end
8
+ end
9
+ 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(event: nil, timestamp: Time.now, **fields)
52
+ def log(*args)
56
53
  warn 'Span#log is deprecated. Please use Span#log_kv instead.'
57
- nil
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
@@ -33,6 +33,8 @@ downstream_span = tracer2.start_span(
33
33
  child_of: inner_span,
34
34
  tags: { 'span.kind' => 'server' }
35
35
  )
36
+ downstream_span.log_kv(event: 'custom-event')
37
+ downstream_span.log_kv(foo: 'bar', baz: 'buz')
36
38
  sleep 0.5
37
39
  downstream_span.finish
38
40
 
data/zipkin.gemspec CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'zipkin'
6
- spec.version = '1.1.0'
6
+ spec.version = '1.2.0'
7
7
  spec.authors = ['SaleMove TechMovers']
8
8
  spec.email = ['techmovers@salemove.com']
9
9
 
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.1.0
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-04 00:00:00.000000000 Z
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