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

Log work item start/end/exception using current's scope logger #4299

Merged
merged 1 commit into from
Jan 6, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,20 @@ async Task ProcessWorkItemAsync()
using (var operation = telemetryClient.StartOperation<RequestTelemetry>(type))
using (logger.BeginScope(processor.GetLoggingContextData(workItem)))
{
var success = await processor.ProcessWorkItemAsync(workItem, cancellationToken);
if (success)
try
{
telemetryScope.SetSuccess();
logger.LogInformation("Processing work item {type}", type);
var success = await processor.ProcessWorkItemAsync(workItem, cancellationToken);
if (success)
{
telemetryScope.SetSuccess();
}
}
catch (Exception e)
{
operation.Telemetry.Success = false;
logger.LogError(e, "Failed to process work item {type}", type);
throw;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.ApplicationInsights;
using Microsoft.DotNet.DarcLib;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
Expand Down