test-tracer 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +118 -12
- data/lib/test/span.rb +6 -0
- data/test-tracer.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4739863b3eb7ab8856bb7aa3a3e0e9bc7c7852b8
|
4
|
+
data.tar.gz: 0c9a7a17bf4adb350b2dc575db89095052b1985d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce894897631dd6c8087aedaabceae8abc43a0fdb7795f41dcbfadffc14b3e274a84523289700877c9ef882acfb3d8360775cc385d93667031ab01af527a7b613
|
7
|
+
data.tar.gz: feb5e4eb5f9fda6b9cf2d99fd182f411f3a6e0ed55ba0f3483dbd385ac991782664f8488378a024671ebd07e4539957a1f23d802bc02d45d1dd9c4a073becf43
|
data/README.md
CHANGED
@@ -28,12 +28,52 @@ In addition to OT compatible methods `Test::Tracer` provides the following metho
|
|
28
28
|
1. `spans` returns all spans, including those in progress.
|
29
29
|
2. `finished_spans` returns only finished spans.
|
30
30
|
|
31
|
+
### Usage
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require "test/tracer"
|
35
|
+
|
36
|
+
describe "Test::Tracer examples" do
|
37
|
+
let(:tracer) { Test::Tracer.new }
|
38
|
+
|
39
|
+
context "when we expect no traces" do
|
40
|
+
it "does not have any traces started" do
|
41
|
+
expect(tracer.spans).to be_empty
|
42
|
+
end
|
43
|
+
|
44
|
+
it "does not have any traces recorded" do
|
45
|
+
expect(tracer.finished_spans).to be_empty
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when we expect traces to be present" do
|
50
|
+
it "does have some traces started" do
|
51
|
+
expect(tracer.spans).not_to be_empty
|
52
|
+
end
|
53
|
+
|
54
|
+
it "does have some traces recorded" do
|
55
|
+
expect(tracer.finished_spans).not_to be_empty
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when we expect exactly N traces" do
|
60
|
+
it "has N traces started" do
|
61
|
+
expect(tracer.spans.size).to eq(N)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "has N traces recorded" do
|
65
|
+
expect(tracer.finished_spans.size).to eq(N)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
31
71
|
## Test::Span
|
32
72
|
|
33
73
|
In addition to OT compatible methods `Test::Span` provides the following methods:
|
34
74
|
|
35
75
|
1. `tracer` returns the tracer the span was created by.
|
36
|
-
1. `in_progress?` informs whether the span is in progress, or it's finished.
|
76
|
+
1. `in_progress?`, `started?`, `finished?` informs whether the span is in progress, or it's finished.
|
37
77
|
2. `start_time` returns when the span was started.
|
38
78
|
2. `end_time` returns when the span was finished, or nil if still in progress.
|
39
79
|
2. `tags` returns the span's tags.
|
@@ -41,6 +81,66 @@ In addition to OT compatible methods `Test::Span` provides the following methods
|
|
41
81
|
|
42
82
|
The modification operations e.g. `operation_name=`, `set_tag`, `set_baggage_item` on a span are not allowed after it's finished. It throws `Test::Span::SpanAlreadyFinished` exception. The same with `finish`. The span can be finished only once.
|
43
83
|
|
84
|
+
### Usage
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
require "test/tracer"
|
88
|
+
|
89
|
+
describe "Test::Span examples" do
|
90
|
+
let(:tracer) { Test::Tracer.new }
|
91
|
+
|
92
|
+
context "when a new span was started" do
|
93
|
+
let(:span) { tracer.start_span("operation name", tags: {'component' => 'ActiveRecord'}) }
|
94
|
+
|
95
|
+
it "is in progress" do
|
96
|
+
expect(span.in_progress?).to eq(true)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "does have the proper name" do
|
100
|
+
expect(span.operation_name).to eq("operation name")
|
101
|
+
end
|
102
|
+
|
103
|
+
it "does include standard OT tags" do
|
104
|
+
expect(span.tags).to include('component' => 'ActiveRecord')
|
105
|
+
end
|
106
|
+
|
107
|
+
it "does not have any log entries" do
|
108
|
+
expect(span.logs).to be_empty
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "when an event was logged" do
|
113
|
+
let(:span) do
|
114
|
+
current_span = tracer.start_span("operation name")
|
115
|
+
current_span.log(event: "exceptional message", severity: Logger::ERROR, pid: $1)
|
116
|
+
current_span
|
117
|
+
end
|
118
|
+
|
119
|
+
it "does have some log entries recorded" do
|
120
|
+
expect(span.logs).not_to be_empty
|
121
|
+
end
|
122
|
+
|
123
|
+
it "includes all the event attributes" do
|
124
|
+
log = span.logs.first
|
125
|
+
expect(log.event).to eq("exceptional message")
|
126
|
+
expect(log.fields).to include(severity: Logger::ERROR)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "when a span was finished" do
|
131
|
+
let(:span) { tracer.start_span("operation name").finish }
|
132
|
+
|
133
|
+
it "is not in progress" do
|
134
|
+
expect(span.in_progress?).to eq(false)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "can't be finished twice" do
|
138
|
+
expect { span.finish }.to raise_error(Test::Span::SpanAlreadyFinished)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
```
|
143
|
+
|
44
144
|
## Test::SpanContext
|
45
145
|
|
46
146
|
Context propagation is fully implemented by the tracer, and is inspired by [Jaeger](http://jaeger.readthedocs.io/en/latest/) and [TraceContext](https://github.com/TraceContext/tracecontext-spec/pull/1/files). In addition to OT compatible methods `Test::SpanContext` provides the following methods:
|
@@ -49,22 +149,28 @@ Context propagation is fully implemented by the tracer, and is inspired by [Jaeg
|
|
49
149
|
1. `span_id` returns the ID of the current span.
|
50
150
|
2. `parent_span_id` returns the ID of the parent span.
|
51
151
|
|
52
|
-
|
152
|
+
|
153
|
+
### Usage
|
53
154
|
|
54
155
|
```ruby
|
55
|
-
|
156
|
+
require "test/tracer"
|
157
|
+
|
158
|
+
describe "Test::SpanContext examples" do
|
159
|
+
let(:tracer) { Test::Tracer.new }
|
56
160
|
|
57
|
-
|
161
|
+
context "when a new span was started as child of root" do
|
162
|
+
let(:root_context) { tracer.start_span("root span").context }
|
163
|
+
let(:child_context) { tracer.start_span("child span", child_of: root_context).context }
|
58
164
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
tracer.spans # => will include both root_span, child_span
|
165
|
+
it "all have the same trace_id" do
|
166
|
+
expect(child_context.trace_id).to eq(root_context.trace_id)
|
167
|
+
end
|
63
168
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
169
|
+
it "propagates parent child relationship" do
|
170
|
+
expect(child_context.parent_span_id).to eq(root_context.span_id)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
68
174
|
```
|
69
175
|
|
70
176
|
## Development
|
data/lib/test/span.rb
CHANGED
data/test-tracer.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-tracer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iaintshine
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentracing
|