@@ -89,6 +89,18 @@ defmodule OpenTelemetryDecoratorTest do
89
89
90
90
@ decorate with_span ( "Example.with_link" , links: [ :_span_link ] )
91
91
def with_link ( _span_link ) , do: :ok
92
+
93
+ @ decorate with_span ( "Example.with_pid" , include: [ :_self ] )
94
+ def with_pid , do: :ok
95
+ end
96
+
97
+ test "pids" do
98
+ expected_pid = inspect ( self ( ) )
99
+
100
+ Example . with_pid ( )
101
+
102
+ span = assert_span ( "Example.with_pid" )
103
+ assert span . attributes == % { "pid" => expected_pid }
92
104
end
93
105
94
106
test "does not modify inputs or function result" do
@@ -188,7 +200,7 @@ defmodule OpenTelemetryDecoratorTest do
188
200
assert % { "app.x" => 1 , "app.y" => 1 } = span . attributes
189
201
end
190
202
191
- test "does not write input parameters not in the include" do
203
+ test "does not write input parameters not in the include (except pid) " do
192
204
defmodule InputExample do
193
205
use OpenTelemetryDecorator
194
206
@@ -202,7 +214,7 @@ defmodule OpenTelemetryDecoratorTest do
202
214
assert { :ok , 3 } = InputExample . inputs ( 1 , 2 )
203
215
204
216
span = assert_span ( "inputs" )
205
- assert span . attributes == % { "app.x" => 1 }
217
+ assert span . attributes == % { "app.x" => 1 , "pid" => inspect ( self ( ) ) }
206
218
end
207
219
208
220
test "overwrites the default result value" do
@@ -225,7 +237,7 @@ defmodule OpenTelemetryDecoratorTest do
225
237
Example . no_include ( include_me: "nope" )
226
238
227
239
span = assert_span ( "Example.no_include" )
228
- assert % { } == span . attributes
240
+ assert span . attributes == % { "pid" => inspect ( self ( ) ) }
229
241
end
230
242
231
243
test "records an exception event" do
@@ -271,7 +283,7 @@ defmodule OpenTelemetryDecoratorTest do
271
283
catch
272
284
:exit , :normal ->
273
285
span = assert_span ( "Example.with_exit" )
274
- assert span . attributes == % { "app.exit" => :normal }
286
+ assert % { "app.exit" => :normal } = span . attributes
275
287
end
276
288
end
277
289
@@ -294,7 +306,7 @@ defmodule OpenTelemetryDecoratorTest do
294
306
catch
295
307
:exit , :shutdown ->
296
308
span = assert_span ( "Example.with_exit" )
297
- assert span . attributes == % { "app.exit" => :shutdown }
309
+ assert % { "app.exit" => :shutdown } = span . attributes
298
310
end
299
311
end
300
312
@@ -318,10 +330,8 @@ defmodule OpenTelemetryDecoratorTest do
318
330
:exit , { :shutdown , _reason } ->
319
331
span = assert_span ( "Example.with_exit" )
320
332
321
- assert span . attributes == % {
322
- "app.exit" => :shutdown ,
323
- "app.shutdown_reason.just" => :chillin
324
- }
333
+ assert % { "app.exit" => :shutdown , "app.shutdown_reason.just" => :chillin } =
334
+ span . attributes
325
335
end
326
336
end
327
337
0 commit comments