request-tracer 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/request_tracer/integration/base.rb +2 -1
- data/lib/request_tracer/integration/sidekiq_handler.rb +4 -2
- data/lib/request_tracer/trace.rb +1 -1
- data/lib/request_tracer/version.rb +1 -1
- data/spec/lib/request_tracer/integration/sidekiq_handler_spec.rb +9 -5
- data/spec/lib/request_tracer/trace_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGUzZDkyNTRiMGFjNTkzZGVhMzE3ZmRmMWFjNGRmZjM4NmQyNDBhZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzgyYTEzMmM0OTYyYTk1NDViYzc2NzExYWUyYTBlYmYwYWE5ZDM4NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWY4MDVjMjRlZTI2MTMxMTYzOTA5ZTdhYTM1ZTIzZmZlYzBiMTlhNWYyMzMz
|
10
|
+
YTc0Zjg2MzFhZjQwNjE1MzYyYjM3MTc2M2I2Mjg3YjRjOTkzN2Y2MWQ0MmZl
|
11
|
+
NjMxZDY1OGQ1MzcyMTZhNmYzNjNhMzcxOThiYmRhY2QwNDgwNDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDZkZmI5NTcxNjNiYzI2ZjcwY2I2Y2VlZGE1ZjI2YTZhNDJmNTkxM2UxZTU4
|
14
|
+
MmZlZDAxYzRlNDMyNmQ5ZTc2NzAzMDY4ODcxNDE3MDVhMmQxZWFkYjRjZTBk
|
15
|
+
MGRjNjhhNjYxNmEyNjgwMDEzYjczZjIyNWFhZTliMzQ4NDQ2OTU=
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module RequestTracer
|
2
2
|
module Integration
|
3
3
|
module Base
|
4
|
+
HEADER_REGEX = /HTTP_X_B3_(.*)/
|
4
5
|
def extract_fields_from_headers(header_hash)
|
5
6
|
header_hash.map do |k,v|
|
6
|
-
special_header =
|
7
|
+
special_header = HEADER_REGEX.match(k)
|
7
8
|
special_header && [B3_REQUIRED_FIELDS_FROM_SHORT_NAMES[special_header[1].downcase], v]
|
8
9
|
end.compact.to_h
|
9
10
|
end
|
data/lib/request_tracer/trace.rb
CHANGED
@@ -71,10 +71,14 @@ describe RequestTracer::Integration::SidekiqHandler do
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
context "when there is an existing trace" do
|
74
|
-
|
75
|
-
|
74
|
+
let(:subtrace) { trace.next_id }
|
75
|
+
before do
|
76
|
+
RequestTracer::Trace.push trace.to_h
|
77
|
+
allow(RequestTracer::Trace).to receive(:record).and_yield(subtrace)
|
78
|
+
end
|
79
|
+
it "passes a sub-trace from the main process to the worker and pushes this on the trace stack in the worker" do
|
76
80
|
TraceableJob.perform_async('foo')
|
77
|
-
expect(result_checker.traces).to eq([
|
81
|
+
expect(result_checker.traces).to eq([subtrace.to_h])
|
78
82
|
end
|
79
83
|
end
|
80
84
|
it "calls the job with the originally given parameters" do
|
@@ -91,7 +95,7 @@ describe RequestTracer::Integration::SidekiqHandler do
|
|
91
95
|
end
|
92
96
|
context "when there is an existing trace" do
|
93
97
|
before { RequestTracer::Trace.push trace.to_h }
|
94
|
-
it "
|
98
|
+
it "does not pass the trace from the main process to the worker and records the worker" do
|
95
99
|
TraceableJob.perform_async('foo')
|
96
100
|
expect(result_checker.traces).to eq([{}])
|
97
101
|
end
|
@@ -106,7 +110,7 @@ describe RequestTracer::Integration::SidekiqHandler do
|
|
106
110
|
end
|
107
111
|
context "when there is an existing trace" do
|
108
112
|
before { RequestTracer::Trace.push trace.to_h }
|
109
|
-
it "
|
113
|
+
it "does not pass the trace from the main process to the worker and records the worker" do
|
110
114
|
TraceableJob.perform_async('foo')
|
111
115
|
expect(result_checker.traces).to eq([{}])
|
112
116
|
end
|
@@ -51,9 +51,17 @@ describe RequestTracer::Trace do
|
|
51
51
|
def push(&blk)
|
52
52
|
described_class.push(previous_trace_hash, &blk)
|
53
53
|
end
|
54
|
+
shared_examples "returning the block value" do
|
55
|
+
let(:block_value) { rand(1000) }
|
56
|
+
it 'returns the value from the block' do
|
57
|
+
returned = push {|t| block_value }
|
58
|
+
expect(returned).to eq(block_value)
|
59
|
+
end
|
60
|
+
end
|
54
61
|
context 'when trace_hash contains a previous trace' do
|
55
62
|
let(:previous_trace) { described_class.create}
|
56
63
|
let(:previous_trace_hash) { previous_trace.to_h }
|
64
|
+
it_behaves_like "returning the block value"
|
57
65
|
it 'keeps the span_id' do
|
58
66
|
push do |t|
|
59
67
|
expect(t.span_id).to eq(previous_trace.span_id)
|
@@ -72,6 +80,7 @@ describe RequestTracer::Trace do
|
|
72
80
|
end
|
73
81
|
context 'when no previous trace exists' do
|
74
82
|
let(:previous_trace_hash) { {} }
|
83
|
+
it_behaves_like "returning the block value"
|
75
84
|
it 'creates a new span_id' do
|
76
85
|
push do |t|
|
77
86
|
expect(t.span_id.i64.to_s).to match /[0-9a-z]+/i
|
@@ -88,5 +97,9 @@ describe RequestTracer::Trace do
|
|
88
97
|
end
|
89
98
|
end
|
90
99
|
end
|
100
|
+
context 'when called with nil' do
|
101
|
+
let(:previous_trace_hash) { nil }
|
102
|
+
it_behaves_like "returning the block value"
|
103
|
+
end
|
91
104
|
end
|
92
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request-tracer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Mauch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|