zipkin 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/zipkin/tracer.rb +27 -10
  3. data/zipkin.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 589baeb482718a12d22419bf94b8df4568a9030f
4
- data.tar.gz: 4a1dbe1355bfa308e793d8a712b17dc6137c883f
3
+ metadata.gz: f40bfd7013e202f01779a9f96f9df369a1a97d5b
4
+ data.tar.gz: 4c8a2b4331229e5e4fd1c683e936d32a43415e83
5
5
  SHA512:
6
- metadata.gz: f760312bb62c3374746f7d1f16515a64fd74d91ea772aafafb38d00e85a15421d1de21779282148beef5a856cf7623f328df0bbc570e5c0c2844c916e5909ca6
7
- data.tar.gz: a1bb857485c8330035f54f772b55f679bfbdb29c17e8e7046aeac7de2d955a479db5de31bc779ac0568279562a0e6be776e13fe04219fd6e727f1bf9f8442950
6
+ metadata.gz: 470a4dc281e01160f3c2f02fd6ce86c15f3ce849b014a845ddd2f0eb2409b02a15534007612a1ce3075ccd04b80dba2d54359ff9de84b772179c323f637d2fb3
7
+ data.tar.gz: ddf4f97347e70b48ec9d458627fb8b39ba88c99519e6d34f0f2408bb4b8d9fc03b5c33f9850d8e37ae0854e692346c352df8a95c5a1187dce19c2d1e7b954998
@@ -63,6 +63,11 @@ module Zipkin
63
63
  # @param carrier [Carrier] A carrier object of the type dictated by the specified `format`
64
64
  def inject(span_context, format, carrier)
65
65
  case format
66
+ when OpenTracing::FORMAT_TEXT_MAP
67
+ carrier['trace-id'] = span_context.trace_id
68
+ carrier['parent-id'] = span_context.parent_id
69
+ carrier['span-id'] = span_context.span_id
70
+ carrier['sampled'] = span_context.sampled? ? '1' : '0'
66
71
  when OpenTracing::FORMAT_RACK
67
72
  carrier['X-B3-TraceId'] = span_context.trace_id
68
73
  carrier['X-B3-ParentSpanId'] = span_context.parent_id
@@ -80,26 +85,38 @@ module Zipkin
80
85
  # @return [SpanContext] the extracted SpanContext or nil if none could be found
81
86
  def extract(format, carrier)
82
87
  case format
88
+ when OpenTracing::FORMAT_TEXT_MAP
89
+ trace_id = carrier['trace-id']
90
+ parent_id = carrier['parent-id']
91
+ span_id = carrier['span-id']
92
+ sampled = carrier['sampled'] == '1'
93
+
94
+ create_span_context(trace_id, span_id, parent_id, sampled)
83
95
  when OpenTracing::FORMAT_RACK
84
96
  trace_id = carrier['HTTP_X_B3_TRACEID']
85
97
  parent_id = carrier['HTTP_X_B3_PARENTSPANID']
86
98
  span_id = carrier['HTTP_X_B3_SPANID']
87
99
  sampled = carrier['HTTP_X_B3_SAMPLED'] == '1'
88
100
 
89
- if trace_id && span_id
90
- SpanContext.new(
91
- trace_id: trace_id,
92
- parent_id: parent_id,
93
- span_id: span_id,
94
- sampled: sampled
95
- )
96
- else
97
- nil
98
- end
101
+ create_span_context(trace_id, span_id, parent_id, sampled)
99
102
  else
100
103
  STDERR.puts "Logasm::Tracer with format #{format} is not supported yet"
101
104
  nil
102
105
  end
103
106
  end
107
+
108
+ private
109
+ def create_span_context(trace_id, span_id, parent_id, sampled)
110
+ if trace_id && span_id
111
+ SpanContext.new(
112
+ trace_id: trace_id,
113
+ parent_id: parent_id,
114
+ span_id: span_id,
115
+ sampled: sampled
116
+ )
117
+ else
118
+ nil
119
+ end
120
+ end
104
121
  end
105
122
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'zipkin'
7
- spec.version = '0.3.1'
7
+ spec.version = '0.4.0'
8
8
  spec.authors = ['SaleMove TechMovers']
9
9
  spec.email = ['techmovers@salemove.com']
10
10
 
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: 0.3.1
4
+ version: 0.4.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: 2017-08-13 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler