rspec-otel 0.0.3 → 0.0.4
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/README.md +4 -0
- data/lib/rspec_otel/matchers/emit_span.rb +49 -5
- data/lib/rspec_otel/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: '081125f70f4963d1a9f414811abbbe65e0113a14131a0cc982a2ce9247b447c5'
|
4
|
+
data.tar.gz: ab28a32cc178212a05e0216ad84a6300eb4509c17537d4499df6d0b2dfa4fd30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d867cbc82ace4ea550c9c14024dc91db343964d749a13075f9a947f4193cdfbbba434270ba85d6de01ae7cdfc919a5ad388a13d7dc903f9dbd06ed1ea4bde0f3
|
7
|
+
data.tar.gz: ff369cb3a9390130bdd354cc5ac99e7b0136525f8d39bb9c5fe793d2142843edc48a9556efe232b2b6397554561d1a17dfb2e39ae36fa6b2494a54af0ab23323
|
data/README.md
CHANGED
@@ -44,10 +44,14 @@ end
|
|
44
44
|
|
45
45
|
Several conditions can be added to the matcher:
|
46
46
|
|
47
|
+
* `as_root` - Will match spans that are the root of a trace.
|
48
|
+
* `as_child` - Will match spans that are not the root of a trace
|
47
49
|
* `with_attributes` - Will match only the spans with the specified attributes.
|
48
50
|
* `without_attributes` - Will only match the spans that do not have the specified attributes
|
49
51
|
* `with_event` - Will match only the spans with the specified event.
|
50
52
|
* `without_event` - Will only match the spans that do not have the specified event
|
53
|
+
* `with_link` - Will match only the spans with the specified link.
|
54
|
+
* `without_link` - Will only match the spans that do not have the specified link
|
51
55
|
* `with_status` - Will match only the spans that have the proper status.
|
52
56
|
* `with_exception` - Will match only the spans that have the specified exception event.
|
53
57
|
* `without_exception` - Will match only the spans that do not have the specified exception event.
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RspecOtel
|
4
4
|
module Matchers
|
5
|
-
class EmitSpan
|
5
|
+
class EmitSpan # rubocop:disable Metrics/ClassLength
|
6
6
|
attr_reader :name
|
7
7
|
|
8
8
|
def initialize(name = nil)
|
@@ -26,6 +26,22 @@ module RspecOtel
|
|
26
26
|
false
|
27
27
|
end
|
28
28
|
|
29
|
+
def as_child
|
30
|
+
@filters << lambda do |span|
|
31
|
+
span.parent_span_id && span.parent_span_id != OpenTelemetry::Trace::INVALID_SPAN_ID
|
32
|
+
end
|
33
|
+
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
def as_root
|
38
|
+
@filters << lambda do |span|
|
39
|
+
span.parent_span_id == OpenTelemetry::Trace::INVALID_SPAN_ID
|
40
|
+
end
|
41
|
+
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
29
45
|
def with_attributes(attributes)
|
30
46
|
@filters << lambda do |span|
|
31
47
|
attributes_match?(span.attributes, attributes)
|
@@ -42,17 +58,39 @@ module RspecOtel
|
|
42
58
|
self
|
43
59
|
end
|
44
60
|
|
61
|
+
def with_link(attributes = {})
|
62
|
+
@filters << lambda do |span|
|
63
|
+
span.links &&
|
64
|
+
link_match?(span.links, attributes)
|
65
|
+
end
|
66
|
+
|
67
|
+
self
|
68
|
+
end
|
69
|
+
|
70
|
+
def without_link(attributes = {})
|
71
|
+
@filters << lambda do |span|
|
72
|
+
span.links.nil? ||
|
73
|
+
!link_match?(span.links, attributes)
|
74
|
+
end
|
75
|
+
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
45
79
|
def with_event(name, attributes = {})
|
46
80
|
@filters << lambda do |span|
|
47
|
-
|
81
|
+
span.events &&
|
82
|
+
event_match?(span.events, OpenTelemetry::SDK::Trace::Event.new(name, attributes))
|
48
83
|
end
|
84
|
+
|
49
85
|
self
|
50
86
|
end
|
51
87
|
|
52
88
|
def without_event(name, attributes = {})
|
53
89
|
@filters << lambda do |span|
|
54
|
-
|
90
|
+
span.events.nil? ||
|
91
|
+
!event_match?(span.events, OpenTelemetry::SDK::Trace::Event.new(name, attributes))
|
55
92
|
end
|
93
|
+
|
56
94
|
self
|
57
95
|
end
|
58
96
|
|
@@ -112,8 +150,6 @@ module RspecOtel
|
|
112
150
|
end
|
113
151
|
|
114
152
|
def event_match?(span_events, event)
|
115
|
-
return true if span_events.nil?
|
116
|
-
|
117
153
|
se = span_events.select do |s|
|
118
154
|
s.name == event.name &&
|
119
155
|
attributes_match?(s.attributes, event.attributes || {})
|
@@ -121,6 +157,14 @@ module RspecOtel
|
|
121
157
|
|
122
158
|
!se.empty?
|
123
159
|
end
|
160
|
+
|
161
|
+
def link_match?(links, attributes)
|
162
|
+
link = links.select do |l|
|
163
|
+
attributes_match?(l.attributes, attributes || {})
|
164
|
+
end
|
165
|
+
|
166
|
+
!link.empty?
|
167
|
+
end
|
124
168
|
end
|
125
169
|
end
|
126
170
|
end
|
data/lib/rspec_otel/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damien MATHIEU
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|