Skip to content

Commit a609ad5

Browse files
authored
Always create spans for temp workflows (#394)
This PR reverts #169 Always create a span for all workflows, including temp workflows.
1 parent d42dd84 commit a609ad5

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

dbos/_context.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,18 @@ def start_workflow(
140140
self,
141141
wfid: Optional[str],
142142
attributes: TracedAttributes,
143-
is_temp_workflow: bool = False,
144143
) -> None:
145144
if wfid is None or len(wfid) == 0:
146145
wfid = self.assign_workflow_id()
147146
self.id_assigned_for_next_workflow = ""
148147
self.workflow_id = wfid
149148
self.function_id = 0
150-
if not is_temp_workflow:
151-
self._start_span(attributes)
149+
self._start_span(attributes)
152150

153-
def end_workflow(
154-
self, exc_value: Optional[BaseException], is_temp_workflow: bool = False
155-
) -> None:
151+
def end_workflow(self, exc_value: Optional[BaseException]) -> None:
156152
self.workflow_id = ""
157153
self.function_id = -1
158-
if not is_temp_workflow:
159-
self._end_span(exc_value)
154+
self._end_span(exc_value)
160155

161156
def is_within_workflow(self) -> bool:
162157
return len(self.workflow_id) > 0
@@ -490,7 +485,6 @@ class EnterDBOSWorkflow(AbstractContextManager[DBOSContext, Literal[False]]):
490485
def __init__(self, attributes: TracedAttributes) -> None:
491486
self.created_ctx = False
492487
self.attributes = attributes
493-
self.is_temp_workflow = attributes["name"] == "temp_wf"
494488
self.saved_workflow_timeout: Optional[int] = None
495489
self.saved_deduplication_id: Optional[str] = None
496490
self.saved_priority: Optional[int] = None
@@ -514,7 +508,7 @@ def __enter__(self) -> DBOSContext:
514508
self.saved_priority = ctx.priority
515509
ctx.priority = None
516510
ctx.start_workflow(
517-
None, self.attributes, self.is_temp_workflow
511+
None, self.attributes
518512
) # Will get from the context's next workflow ID
519513
return ctx
520514

@@ -526,7 +520,7 @@ def __exit__(
526520
) -> Literal[False]:
527521
ctx = assert_current_dbos_context()
528522
assert ctx.is_within_workflow()
529-
ctx.end_workflow(exc_value, self.is_temp_workflow)
523+
ctx.end_workflow(exc_value)
530524
# Restore the saved workflow timeout
531525
ctx.workflow_timeout_ms = self.saved_workflow_timeout
532526
# Clear any propagating timeout

dbos/_core.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,11 +1187,6 @@ def temp_wf_sync(*args: Any, **kwargs: Any) -> Any:
11871187
async def temp_wf_async(*args: Any, **kwargs: Any) -> Any:
11881188
return await wrapper(*args, **kwargs)
11891189

1190-
# Other code in transact-py depends on the name of temporary workflow functions to be "temp_wf"
1191-
# so set the name of both sync and async temporary workflow functions explicitly
1192-
temp_wf_sync.__name__ = "temp_wf"
1193-
temp_wf_async.__name__ = "temp_wf"
1194-
11951190
temp_wf = temp_wf_async if inspect.iscoroutinefunction(func) else temp_wf_sync
11961191
wrapped_wf = workflow_wrapper(dbosreg, temp_wf)
11971192
set_dbos_func_name(temp_wf, "<temp>." + step_name)

0 commit comments

Comments
 (0)