Skip to content

Commit 15a6b5f

Browse files
authored
feat: after_stop.publish now take two arguments
feat: after_stop.publish now take two arguments
2 parents 1f6a7c5 + a870424 commit 15a6b5f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/datadog/tracing/span_operation.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def measure
171171
# Stop the span first, so timing is a more accurate.
172172
# If the span failed to start, timing may be inaccurate,
173173
# but this is not really a serious concern.
174-
stop
174+
stop(exception: e)
175175

176176
# Trigger the on_error event
177177
events.on_error.publish(self, e)
@@ -212,7 +212,7 @@ def start(start_time = nil)
212212
#
213213
# steep:ignore:start
214214
# Steep issue fixed in https://github.com/soutaro/steep/pull/1467
215-
def stop(stop_time = nil)
215+
def stop(stop_time = nil, exception: nil)
216216
# A span should not be stopped twice. Note that this is not thread-safe,
217217
# stop is called from multiple threads, a given span might be stopped
218218
# several times. Again, one should not do this, so this test is more a
@@ -230,7 +230,7 @@ def stop(stop_time = nil)
230230
@duration_end = stop_time.nil? ? duration_marker : nil
231231

232232
# Trigger after_stop event
233-
events.after_stop.publish(self)
233+
events.after_stop.publish(self, exception)
234234

235235
self
236236
end

sig/datadog/tracing/span_operation.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module Datadog
6262

6363
def start: (?untyped? start_time) -> self
6464

65-
def stop: (?untyped? stop_time) -> self?
65+
def stop: (?Time? stop_time, ?exception: Exception) -> self?
6666

6767
def started?: () -> untyped
6868

spec/datadog/tracing/span_operation_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@
388388

389389
it do
390390
expect(callback_spy).to have_received(:before_start).with(span_op).ordered
391-
expect(callback_spy).to have_received(:after_stop).with(span_op).ordered
391+
expect(callback_spy).to have_received(:after_stop).with(span_op, nil).ordered
392392
expect(callback_spy).to have_received(:after_finish).with(kind_of(Datadog::Tracing::Span), span_op).ordered
393393
expect(callback_spy).to_not have_received(:on_error)
394394
end
@@ -440,7 +440,7 @@
440440

441441
it do
442442
expect(callback_spy).to have_received(:before_start).with(span_op).ordered
443-
expect(callback_spy).to have_received(:after_stop).with(span_op).ordered
443+
expect(callback_spy).to have_received(:after_stop).with(span_op, error).ordered
444444
expect(callback_spy).to have_received(:on_error).with(span_op, error).ordered
445445
expect(callback_spy).to have_received(:after_finish).with(kind_of(Datadog::Tracing::Span), span_op).ordered
446446
end
@@ -472,7 +472,7 @@
472472

473473
it do
474474
expect(callback_spy).to have_received(:before_start).with(span_op).ordered
475-
expect(callback_spy).to have_received(:after_stop).with(span_op).ordered
475+
expect(callback_spy).to have_received(:after_stop).with(span_op, error).ordered
476476
expect(callback_spy).to have_received(:on_error).with(span_op, error).ordered
477477
expect(callback_spy).to have_received(:after_finish).with(kind_of(Datadog::Tracing::Span), span_op).ordered
478478
end
@@ -663,7 +663,7 @@
663663
include_context 'callbacks'
664664
before { stop }
665665
it do
666-
expect(callback_spy).to have_received(:after_stop).with(span_op)
666+
expect(callback_spy).to have_received(:after_stop).with(span_op, nil)
667667
expect(callback_spy).to have_received(:before_start).with(span_op)
668668
expect(callback_spy).to_not have_received(:after_finish)
669669
end
@@ -685,7 +685,7 @@
685685
include_context 'callbacks'
686686
before { stop }
687687
it do
688-
expect(callback_spy).to have_received(:after_stop).with(span_op)
688+
expect(callback_spy).to have_received(:after_stop).with(span_op, nil)
689689
expect(callback_spy).to_not have_received(:before_start)
690690
expect(callback_spy).to_not have_received(:after_finish)
691691
end
@@ -771,7 +771,7 @@
771771
include_context 'callbacks'
772772
before { finish }
773773
it do
774-
expect(callback_spy).to have_received(:after_stop).with(span_op).ordered
774+
expect(callback_spy).to have_received(:after_stop).with(span_op, nil).ordered
775775
expect(callback_spy).to have_received(:after_finish).with(kind_of(Datadog::Tracing::Span), span_op).ordered
776776
end
777777
end

0 commit comments

Comments
 (0)