Skip to content

Commit 81acf6d

Browse files
chore(tracing): deprecate Span.finished setter and Span.finish_with_ancestors() (#15187)
## Description A few more Span attributes/methods to deprecate in 4.0. ## Testing <!-- Describe your testing strategy or note what tests are included --> ## Risks <!-- Note any risks associated with this change, or "None" if no risks --> ## Additional Notes <!-- Any other information that would be helpful for reviewers --> --------- Co-authored-by: Yun Kim <[email protected]>
1 parent 11ed07a commit 81acf6d

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

ddtrace/_trace/span.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ def finished(self, value: bool) -> None:
282282
If the span is already finished and a truthy value is provided
283283
no action will occur.
284284
"""
285+
deprecate(
286+
prefix="The finished setter is deprecated",
287+
message="""Use the finish() method to finish a span.""",
288+
category=DDTraceDeprecationWarning,
289+
removal_version="4.0.0",
290+
)
285291
if value:
286292
if not self.finished:
287293
self.duration_ns = Time.time_ns() - self.start_ns
@@ -820,7 +826,7 @@ def _set_link_or_append_pointer(self, link: Union[SpanLink, _SpanPointer]) -> No
820826
except ValueError:
821827
self._links.append(link)
822828

823-
def finish_with_ancestors(self) -> None:
829+
def _finish_with_ancestors(self) -> None:
824830
"""Finish this span along with all (accessible) ancestors of this span.
825831
826832
This method is useful if a sudden program shutdown is required and finishing
@@ -831,6 +837,15 @@ def finish_with_ancestors(self) -> None:
831837
span.finish()
832838
span = span._parent
833839

840+
@removals.remove(removal_version="4.0.0")
841+
def finish_with_ancestors(self) -> None:
842+
"""Finish this span along with all (accessible) ancestors of this span.
843+
844+
This method is useful if a sudden program shutdown is required and finishing
845+
the trace is desired.
846+
"""
847+
self._finish_with_ancestors()
848+
834849
def __enter__(self) -> "Span":
835850
return self
836851

ddtrace/contrib/internal/aws_lambda/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _crash_flush(self, _, __):
103103

104104
current_span = tracer.current_span()
105105
if current_span is not None:
106-
current_span.finish_with_ancestors()
106+
current_span._finish_with_ancestors()
107107

108108
def _remove_alarm_signal(self):
109109
"""Removes the handler set for the signal `SIGALRM`."""
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
deprecations:
3+
- |
4+
tracing: ``Span.finished`` setter is deprecated, use ``Span.finish()`` method instead.
5+
- |
6+
tracing: ``Span.finish_with_ancestors()`` is deprecated with no alternative.

0 commit comments

Comments
 (0)