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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46e54f012c081598681f2f5da8a961f29cb8656b8a21fa1877358724c2fa20b8
4
- data.tar.gz: c22b07513bdca3173bdedbf1948d00f09907f669142f4d186c5f66808bb4d959
3
+ metadata.gz: 2d468909c2b28497b50dba2901e92f651ec45b555cca6fc1453258140e996f0d
4
+ data.tar.gz: 79508ca6c29d18906610ddf0950e33951e05f5db185e169af895a3982df3c40d
5
5
  SHA512:
6
- metadata.gz: f5b58005b5f1fe570f50cb36b66b7f72d6e27a620fee2453b3bc7b74e46202ddebb16b5b6d1e71d3a698f236ffebe7cd1ad60de128103f7a40929f12180eca82
7
- data.tar.gz: dc910caca3ce2234aa5e12bc2c8363a98a711f717e84e05943a6246f0c462fd614486617cf9a9211721da92abb3d01bee18e1e6a0c66e7220c340395f56f79fd
6
+ metadata.gz: e3f979dfa0f2be704ab85940dd4e6d6738fd9c587750b04929304eb72b55b122375a7e1c3e8ac2b8fac238aa8c154d24a8dae86e07bdf36f1d0e974a604cdbf5
7
+ data.tar.gz: 8bc0b4f4b2ee75570563d0a4aaba3823a8f6b6a8ccb1c99c0063e38726e9cedf749ab9722be3eb3837db0947e8f43b2ee44c47df6a8e6f378815adf7a6ceca58
@@ -25,7 +25,7 @@ deploy:
25
25
  on:
26
26
  tags: true
27
27
  repo: openzipkin/zipkin-ruby
28
- condition: "$TRAVIS_RUBY_VERSION == 2.7"
28
+ condition: $TRAVIS_RUBY_VERSION == 2.7 && $BUNDLE_GEMFILE == $TRAVIS_BUILD_DIR/gemfiles/faraday_1.x.gemfile
29
29
 
30
30
  notifications:
31
31
  webhooks:
@@ -1,3 +1,6 @@
1
+ # 0.45.0
2
+ * Add a `trace_context` option to the TraceWrapper utility class to retrieve trace data.
3
+
1
4
  # 0.44.0
2
5
  * Allow Faraday 1.x.
3
6
 
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
 
@@ -115,21 +115,21 @@ module Trace
115
115
  end
116
116
 
117
117
  def next_id
118
- TraceId.new(@trace_id, @span_id, ZipkinTracer::TraceGenerator.new.generate_id, @sampled, @flags)
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
- @flags & Flags::DEBUG == Flags::DEBUG
123
+ flags & Flags::DEBUG == Flags::DEBUG
124
124
  end
125
125
 
126
126
  def sampled?
127
- debug? || ['1', 'true'].include?(@sampled)
127
+ debug? || %w[1 true].include?(sampled)
128
128
  end
129
129
 
130
130
  def to_s
131
- "TraceId(trace_id = #{@trace_id.to_s}, parent_id = #{@parent_id.to_s}, span_id = #{@span_id.to_s}," \
132
- " sampled = #{@sampled.to_s}, flags = #{@flags.to_s}, shared = #{@shared.to_s})"
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
- def self.wrap_in_custom_span(config, span_name, span_kind: Trace::Span::Kind::SERVER, app: nil)
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 = ZipkinTracer::TraceGenerator.new.next_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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZipkinTracer
4
- VERSION = '0.44.0'
4
+ VERSION = '0.45.0'
5
5
  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.44.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-04-16 00:00:00.000000000 Z
17
+ date: 2020-05-22 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: faraday