Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exceptions to OTel client spans and minor 1.24 server test fixes #272

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ public override async Task<WorkflowHandle<TWorkflow, TResult>> StartWorkflowAsyn
{
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<WorkflowUpdateHandle<TResult>> StartWorkflowUpdateAsy
{
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 @@ await handle.BackfillAsync(new List<ScheduleBackfill>
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 @@ await WorkflowWorkerTests.AssertTaskFailureContainsEventuallyAsync(
"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 @@ await WorkflowWorkerTests.AssertTaskFailureContainsEventuallyAsync(
"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