rspec-otel 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rspec_otel/matchers/emit_span.rb +35 -10
- data/lib/rspec_otel/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b966349d533ad57a8ee5fc1fd79b7ed99922beb6aad8fc1fb59e97d8062cdf5e
|
|
4
|
+
data.tar.gz: e167fba956f24f180846574e5b87214f906b0d35377d7b92230df99aa6244dc2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f19d4e4b8c94818c8d11e373380fc527c8e61f875e24189c3fa401a38d49f1647eb4f5e4862dea702de3397fd2ec81ee6deca4612056678c8de9faa90208eae
|
|
7
|
+
data.tar.gz: a3320a67e728db92483d66a7cad492abbc7785cb7088417ab8e9e23b1648db348b0b32e869b308d6369a0cb7c267c613a17e7f0f810d11ab5138a4cbb6072b98
|
|
@@ -8,19 +8,24 @@ module RspecOtel
|
|
|
8
8
|
def initialize(name = nil)
|
|
9
9
|
@name = name
|
|
10
10
|
@filters = []
|
|
11
|
+
@before_spans = []
|
|
12
|
+
@closest_span = nil
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
@filters << name_filter
|
|
13
15
|
end
|
|
14
16
|
|
|
15
|
-
def matches?(block)
|
|
16
|
-
before_spans = []
|
|
17
|
+
def matches?(block) # rubocop:disable Metrics/MethodLength
|
|
17
18
|
if block.respond_to?(:call)
|
|
18
|
-
before_spans = RspecOtel.exporter.finished_spans
|
|
19
|
+
@before_spans = RspecOtel.exporter.finished_spans
|
|
19
20
|
block.call
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
closest_count = 0
|
|
24
|
+
(RspecOtel.exporter.finished_spans - @before_spans).each do |span|
|
|
25
|
+
count = @filters.count { |f| f.call(span) }
|
|
26
|
+
@closest_span = span if count > closest_count
|
|
27
|
+
closest_count = count
|
|
28
|
+
return true if count == @filters.count
|
|
24
29
|
end
|
|
25
30
|
|
|
26
31
|
false
|
|
@@ -110,7 +115,17 @@ module RspecOtel
|
|
|
110
115
|
end
|
|
111
116
|
|
|
112
117
|
def failure_message
|
|
113
|
-
|
|
118
|
+
closest = closest_span
|
|
119
|
+
expect_content = "expected span #{failure_match_description} #{printable_name} to have been emitted"
|
|
120
|
+
|
|
121
|
+
case closest
|
|
122
|
+
when nil
|
|
123
|
+
"#{expect_content}, but there were no spans emitted at all"
|
|
124
|
+
when OpenTelemetry::SDK::Trace::SpanData
|
|
125
|
+
"#{expect_content}, but it couldn't be found. Found a close matching span named `#{closest.name}`"
|
|
126
|
+
else
|
|
127
|
+
raise "I don't know what to do with a #{closest.class} span"
|
|
128
|
+
end
|
|
114
129
|
end
|
|
115
130
|
|
|
116
131
|
def failure_message_when_negated
|
|
@@ -123,6 +138,12 @@ module RspecOtel
|
|
|
123
138
|
|
|
124
139
|
private
|
|
125
140
|
|
|
141
|
+
def closest_span
|
|
142
|
+
return @closest_span unless @closest_span.nil?
|
|
143
|
+
|
|
144
|
+
(RspecOtel.exporter.finished_spans - @before_spans).first
|
|
145
|
+
end
|
|
146
|
+
|
|
126
147
|
def failure_match_description
|
|
127
148
|
case name
|
|
128
149
|
when String
|
|
@@ -141,8 +162,8 @@ module RspecOtel
|
|
|
141
162
|
end
|
|
142
163
|
end
|
|
143
164
|
|
|
144
|
-
def
|
|
145
|
-
|
|
165
|
+
def name_filter
|
|
166
|
+
lambda do |span|
|
|
146
167
|
case name
|
|
147
168
|
when String
|
|
148
169
|
span.name == name
|
|
@@ -154,9 +175,13 @@ module RspecOtel
|
|
|
154
175
|
|
|
155
176
|
def exception_attributes(exception)
|
|
156
177
|
attributes = {}
|
|
157
|
-
|
|
178
|
+
return attributes if exception.nil?
|
|
179
|
+
|
|
180
|
+
if exception.is_a?(Exception)
|
|
158
181
|
attributes['exception.type'] = exception.class.to_s
|
|
159
182
|
attributes['exception.message'] = exception.message
|
|
183
|
+
else
|
|
184
|
+
attributes['exception.type'] = exception.to_s
|
|
160
185
|
end
|
|
161
186
|
|
|
162
187
|
attributes
|
data/lib/rspec_otel/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-otel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Damien MATHIEU
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: opentelemetry-api
|
|
@@ -85,7 +84,6 @@ licenses:
|
|
|
85
84
|
- MIT
|
|
86
85
|
metadata:
|
|
87
86
|
rubygems_mfa_required: 'true'
|
|
88
|
-
post_install_message:
|
|
89
87
|
rdoc_options: []
|
|
90
88
|
require_paths:
|
|
91
89
|
- lib
|
|
@@ -100,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
100
98
|
- !ruby/object:Gem::Version
|
|
101
99
|
version: '0'
|
|
102
100
|
requirements: []
|
|
103
|
-
rubygems_version: 3.
|
|
104
|
-
signing_key:
|
|
101
|
+
rubygems_version: 3.6.9
|
|
105
102
|
specification_version: 4
|
|
106
103
|
summary: RSpec matchers for the OpenTelemetry framework
|
|
107
104
|
test_files: []
|