Skip to content

Commit 97be072

Browse files
committed
PR Feedback
1 parent b25cc70 commit 97be072

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

durabletask/internal/tracing.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ def start_orchestration_span(
269269
# capture "now" so the value can be fed back to the sidecar.
270270
start_time_ns: Optional[int] = None
271271
if orchestration_trace_context is not None and orchestration_trace_context.HasField("spanStartTime"):
272-
start_dt = orchestration_trace_context.spanStartTime.ToDatetime()
273-
start_time_ns = int(start_dt.timestamp() * 1e9)
272+
start_time_ns = orchestration_trace_context.spanStartTime.ToNanoseconds()
274273
else:
275274
start_time_ns = time.time_ns()
276275

@@ -318,7 +317,8 @@ def detach_orchestration_tokens(tokens: Any) -> None:
318317
if tokens is None:
319318
return
320319
parent_token, span_token = tokens
321-
otel_context.detach(span_token)
320+
if span_token is not None:
321+
otel_context.detach(span_token)
322322
if parent_token is not None:
323323
otel_context.detach(parent_token)
324324

@@ -567,10 +567,7 @@ def build_orchestration_trace_context(
567567

568568
if start_time_ns is not None:
569569
ts = timestamp_pb2.Timestamp()
570-
seconds = int(start_time_ns // 1e9)
571-
nanos = int(start_time_ns % 1e9)
572-
ts.seconds = seconds
573-
ts.nanos = nanos
570+
ts.FromNanoseconds(start_time_ns)
574571
ctx.spanStartTime.CopyFrom(ts)
575572

576573
return ctx

durabletask/worker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,8 @@ def _execute_orchestrator(
718718
else:
719719
# Intermediate dispatch — keep the span alive for later,
720720
# but detach context tokens for this call.
721-
self._orchestration_spans[instance_id] = (span, orch_trace_ctx)
721+
if span is not None:
722+
self._orchestration_spans[instance_id] = (span, orch_trace_ctx)
722723
tracing.detach_orchestration_tokens(tokens)
723724

724725
res = pb.OrchestratorResponse(

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ dependencies = [
3333

3434
[project.optional-dependencies]
3535
opentelemetry = [
36-
"opentelemetry-api>=1.0.0"
36+
"opentelemetry-api>=1.0.0",
37+
"opentelemetry-sdk>=1.0.0"
3738
]
3839

3940
[project.urls]

tests/durabletask/test_tracing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,13 +1315,14 @@ def orchestrator(ctx: task.OrchestrationContext, _):
13151315
assert ptc.traceParent != ""
13161316

13171317
# Dispatch 2: activity completes
1318+
activity_name = task.get_name(dummy_activity)
13181319
w._execute_orchestrator(pb.OrchestratorRequest(
13191320
instanceId=TEST_INSTANCE_ID,
13201321
pastEvents=[
13211322
helpers.new_orchestrator_started_event(schedule_time),
13221323
helpers.new_execution_started_event(
13231324
name, TEST_INSTANCE_ID, encoded_input=None),
1324-
helpers.new_task_scheduled_event(1, name),
1325+
helpers.new_task_scheduled_event(1, activity_name),
13251326
],
13261327
newEvents=[
13271328
helpers.new_orchestrator_started_event(complete_time),

0 commit comments

Comments
 (0)