zipkin-tracer 0.44.0 → 0.45.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +3 -0
- data/README.md +12 -0
- data/lib/zipkin-tracer/trace.rb +5 -5
- data/lib/zipkin-tracer/trace_wrapper.rb +13 -2
- data/lib/zipkin-tracer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d468909c2b28497b50dba2901e92f651ec45b555cca6fc1453258140e996f0d
|
4
|
+
data.tar.gz: 79508ca6c29d18906610ddf0950e33951e05f5db185e169af895a3982df3c40d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3f979dfa0f2be704ab85940dd4e6d6738fd9c587750b04929304eb72b55b122375a7e1c3e8ac2b8fac238aa8c154d24a8dae86e07bdf36f1d0e974a604cdbf5
|
7
|
+
data.tar.gz: 8bc0b4f4b2ee75570563d0a4aaba3823a8f6b6a8ccb1c99c0063e38726e9cedf749ab9722be3eb3837db0947e8f43b2ee44c47df6a8e6f378815adf7a6ceca58
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -242,6 +242,18 @@ TraceWrapper.wrap_in_custom_span(config, "custom span") do |span|
|
|
242
242
|
end
|
243
243
|
```
|
244
244
|
|
245
|
+
The `trace_context:` keyword argument can be used to retrieve trace data:
|
246
|
+
```ruby
|
247
|
+
trace_context = {
|
248
|
+
trace_id: '234555b04cf7e099',
|
249
|
+
span_id: '234555b04cf7e099',
|
250
|
+
sampled: 'true'
|
251
|
+
}
|
252
|
+
|
253
|
+
TraceWrapper.wrap_in_custom_span(config, "custom span", trace_context: trace_context) do |span|
|
254
|
+
:
|
255
|
+
end
|
256
|
+
```
|
245
257
|
|
246
258
|
## Development
|
247
259
|
|
data/lib/zipkin-tracer/trace.rb
CHANGED
@@ -115,21 +115,21 @@ module Trace
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def next_id
|
118
|
-
TraceId.new(
|
118
|
+
TraceId.new(trace_id, span_id, ZipkinTracer::TraceGenerator.new.generate_id, sampled, flags)
|
119
119
|
end
|
120
120
|
|
121
121
|
# the debug flag is used to ensure the trace passes ALL samplers
|
122
122
|
def debug?
|
123
|
-
|
123
|
+
flags & Flags::DEBUG == Flags::DEBUG
|
124
124
|
end
|
125
125
|
|
126
126
|
def sampled?
|
127
|
-
debug? || [
|
127
|
+
debug? || %w[1 true].include?(sampled)
|
128
128
|
end
|
129
129
|
|
130
130
|
def to_s
|
131
|
-
"TraceId(trace_id = #{
|
132
|
-
" sampled = #{
|
131
|
+
"TraceId(trace_id = #{trace_id}, parent_id = #{parent_id}, span_id = #{span_id}," \
|
132
|
+
" sampled = #{sampled}, flags = #{flags}, shared = #{shared})"
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
@@ -1,10 +1,13 @@
|
|
1
1
|
module ZipkinTracer
|
2
2
|
class TraceWrapper
|
3
|
-
|
3
|
+
REQUIRED_KEYS = %i[trace_id span_id].freeze
|
4
|
+
KEYS = %i[trace_id parent_id span_id sampled].freeze
|
5
|
+
|
6
|
+
def self.wrap_in_custom_span(config, span_name, span_kind: Trace::Span::Kind::SERVER, app: nil, trace_context: nil)
|
4
7
|
raise ArgumentError, "you must provide a block" unless block_given?
|
5
8
|
|
6
9
|
initialize_tracer(app, config)
|
7
|
-
trace_id =
|
10
|
+
trace_id = next_trace_id(trace_context)
|
8
11
|
|
9
12
|
ZipkinTracer::TraceContainer.with_trace_id(trace_id) do
|
10
13
|
if trace_id.sampled?
|
@@ -24,5 +27,13 @@ module ZipkinTracer
|
|
24
27
|
zipkin_config = ZipkinTracer::Config.new(app, config).freeze
|
25
28
|
ZipkinTracer::TracerFactory.new.tracer(zipkin_config)
|
26
29
|
end
|
30
|
+
|
31
|
+
def self.next_trace_id(trace_context)
|
32
|
+
if trace_context.is_a?(Hash) && REQUIRED_KEYS.all? { |key| trace_context.key?(key) }
|
33
|
+
Trace::TraceId.new(*trace_context.values_at(*KEYS), Trace::Flags::EMPTY).next_id
|
34
|
+
else
|
35
|
+
ZipkinTracer::TraceGenerator.new.next_trace_id
|
36
|
+
end
|
37
|
+
end
|
27
38
|
end
|
28
39
|
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.
|
4
|
+
version: 0.45.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franklin Hu
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2020-
|
17
|
+
date: 2020-05-22 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: faraday
|