You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add OpenTelemetry error recording with Activity.AddException polyfill (#446)
* Add OpenTelemetry error recording with Activity.AddException polyfill
Addresses #429 - telemetry activities were not consistently marked as errors when exceptions occurred. This adds a net8 polyfill for the .NET 10 Activity.AddException API, a SetErrorStatus extension that both sets ActivityStatusCode.Error and records exception events per OTel semantic conventions, and consistent error recording across all activity scopes (jobs, queues, work items, messaging, locks).
Co-authored-by: Cursor <cursoragent@cursor.com>
* Remove redundant Activity.Current error status from WorkItemJob
The job runner already sets error status on the parent activity for any non-success, non-cancelled JobResult. This call was setting it on Activity.Current before the child activity was created, duplicating work the runner handles.
Co-authored-by: Cursor <cursoragent@cursor.com>
* PR Feedback
* Apply suggestion from @niemyjski
* PR feedback
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy file name to clipboardExpand all lines: src/Foundatio/Jobs/WorkItemJob/WorkItemJob.cs
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
usingSystem;
1
+
usingSystem;
2
2
usingSystem.Collections.Concurrent;
3
3
usingSystem.Diagnostics;
4
4
usingSystem.Threading;
@@ -93,6 +93,7 @@ public async Task<JobResult> ProcessAsync(IQueueEntry<WorkItemData> queueEntry,
93
93
}
94
94
catch(Exceptionex)
95
95
{
96
+
activity?.SetErrorStatus(ex,$"Abandoning {queueEntry.Value.Type} work item: {queueEntry.Id}: Failed to parse {workItemDataType.Name} work item data");
96
97
awaitqueueEntry.AbandonAsync().AnyContext();
97
98
returnJobResult.FromException(ex,$"Abandoning {queueEntry.Value.Type} work item: {queueEntry.Id}: Failed to parse {workItemDataType.Name} work item data");
98
99
}
@@ -101,7 +102,9 @@ public async Task<JobResult> ProcessAsync(IQueueEntry<WorkItemData> queueEntry,
101
102
if(handler==null)
102
103
{
103
104
awaitqueueEntry.CompleteAsync().AnyContext();
104
-
returnJobResult.FailedWithMessage($"Completing {queueEntry.Value.Type} work item: {queueEntry.Id}: Handler for type {workItemDataType.Name} not registered");
105
+
varresult=JobResult.FailedWithMessage($"Completing {queueEntry.Value.Type} work item: {queueEntry.Id}: Handler for type {workItemDataType.Name} not registered");
_logger.LogTrace("Getting metrics queue stats for {QueueName} ({QueueId}): Next update scheduled for {NextQueueStatsUpdate:O}",_options.Name,QueueId,_nextQueueStatsUpdate);
0 commit comments