Skip to content

Commit

Permalink
Add exceptions to OTel client spans and minor 1.24 server test fixes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz committed Jun 12, 2024
1 parent af5e004 commit bf26249
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
40 changes: 36 additions & 4 deletions src/Temporalio.Extensions.OpenTelemetry/TracingInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,15 @@ internal ClientOutbound(TracingInterceptor root, ClientOutboundInterceptor next)
{
input = input with { Headers = headers };
}
return await base.StartWorkflowAsync<TWorkflow, TResult>(input).ConfigureAwait(false);
try
{
return await base.StartWorkflowAsync<TWorkflow, TResult>(input).ConfigureAwait(false);
}
catch (Exception e)
{
RecordExceptionWithStatus(activity, e);
throw;
}
}
}

Expand All @@ -212,7 +220,15 @@ public override async Task SignalWorkflowAsync(SignalWorkflowInput input)
{
input = input with { Headers = headers };
}
await base.SignalWorkflowAsync(input).ConfigureAwait(false);
try
{
await base.SignalWorkflowAsync(input).ConfigureAwait(false);
}
catch (Exception e)
{
RecordExceptionWithStatus(activity, e);
throw;
}
}
}

Expand All @@ -228,7 +244,15 @@ public override async Task<TResult> QueryWorkflowAsync<TResult>(QueryWorkflowInp
{
input = input with { Headers = headers };
}
return await base.QueryWorkflowAsync<TResult>(input).ConfigureAwait(false);
try
{
return await base.QueryWorkflowAsync<TResult>(input).ConfigureAwait(false);
}
catch (Exception e)
{
RecordExceptionWithStatus(activity, e);
throw;
}
}
}

Expand All @@ -245,7 +269,15 @@ public override async Task<TResult> QueryWorkflowAsync<TResult>(QueryWorkflowInp
{
input = input with { Headers = headers };
}
return await base.StartWorkflowUpdateAsync<TResult>(input).ConfigureAwait(false);
try
{
return await base.StartWorkflowUpdateAsync<TResult>(input).ConfigureAwait(false);
}
catch (Exception e)
{
RecordExceptionWithStatus(activity, e);
throw;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion tests/Temporalio.Tests/Client/TemporalClientScheduleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ public async Task CreateScheduleAsync_Backfill_CreatesProperActions()
EndAt: now,
Overlap: ScheduleOverlapPolicy.AllowAll),
});
Assert.Equal(6, (await handle.DescribeAsync()).Info.NumActions);
// Servers < 1.24 this is 6, servers >= 1.24 this is 7
var numActions = (await handle.DescribeAsync()).Info.NumActions;
Assert.True(numActions == 6 || numActions == 7, $"Invalid num actions: {numActions}");

// Delete when done
await TestUtils.DeleteAllSchedulesAsync(Client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,6 @@ public async Task TracingInterceptor_TaskFailures_HaveProperSpans()
"RunWorkflow:TracingWorkflow",
Parent: "StartWorkflow:TracingWorkflow",
Tags: workflowRunTags),
// Validate update
new(
"ValidateUpdate:UpdateTaskFailure",
Parent: "StartWorkflow:TracingWorkflow",
Tags: workflowRunTags,
// Ignore link because client-side send update not captured since it didn't complete
// TODO(cretz): This may need to change when server bug that doesn't finish update
// poll on workflow terminate is complete.
IgnoreLinks: true),
// Handle update
new(
"HandleUpdate:UpdateTaskFailure",
Expand All @@ -413,7 +404,13 @@ public async Task TracingInterceptor_TaskFailures_HaveProperSpans()
"WorkflowTaskFailure:UpdateTaskFailure",
Parent: "HandleUpdate:UpdateTaskFailure",
Tags: workflowRunTags,
Events: new[] { ActivityAssertion.ExceptionEvent("some message") }));
Events: new[] { ActivityAssertion.ExceptionEvent("some message") }),
// On 1.24+, updates properly fail on client when workflow terminated
new(
"UpdateWorkflow:UpdateTaskFailure",
Parent: null,
Tags: workflowTags,
Events: new[] { ActivityAssertion.ExceptionEvent("workflow execution already completed") }));
}

[Fact]
Expand Down Expand Up @@ -509,7 +506,8 @@ public async Task TracingInterceptor_ProperFailures_HaveProperSpans()
new(
"QueryWorkflow:QueryFailure",
Parent: null,
Tags: workflowTags),
Tags: workflowTags,
Events: new[] { ActivityAssertion.ExceptionEvent("fail3") }),
// Handle query
new(
"HandleQuery:QueryFailure",
Expand Down

0 comments on commit bf26249

Please sign in to comment.