-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation for workflow log tracing (#1176)
* Initial setup for workflow log tracing Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Created log sink for E2E tests using serilog Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Formatting Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Addressing feedback on review Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Addressing some review comments Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Addressing more feedbck in the workflow e2e test Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> --------- Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
- Loading branch information
1 parent
2332388
commit 39a38f6
Showing
7 changed files
with
176 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// ------------------------------------------------------------------------ | ||
// Copyright 2022 The Dapr Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ------------------------------------------------------------------------ | ||
|
||
namespace Dapr.Workflow | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
/// <summary> | ||
/// Defines runtime options for workflows. | ||
/// </summary> | ||
internal sealed class WorkflowLoggingService : IHostedService | ||
{ | ||
private readonly ILogger<WorkflowLoggingService> logger; | ||
private static readonly HashSet<string> registeredWorkflows = new(); | ||
private static readonly HashSet<string> registeredActivities = new(); | ||
|
||
public WorkflowLoggingService(ILogger<WorkflowLoggingService> logger, IConfiguration configuration) | ||
{ | ||
this.logger = logger; | ||
|
||
} | ||
public Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
this.logger.Log(LogLevel.Information, "WorkflowLoggingService started"); | ||
|
||
this.logger.Log(LogLevel.Information, "List of registered workflows"); | ||
foreach (string item in registeredWorkflows) | ||
{ | ||
this.logger.Log(LogLevel.Information, item); | ||
} | ||
|
||
this.logger.Log(LogLevel.Information, "List of registered activities:"); | ||
foreach (string item in registeredActivities) | ||
{ | ||
this.logger.Log(LogLevel.Information, item); | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
public Task StopAsync(CancellationToken cancellationToken) | ||
{ | ||
this.logger.Log(LogLevel.Information, "WorkflowLoggingService stopped"); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
public static void LogWorkflowName(string workflowName) | ||
{ | ||
registeredWorkflows.Add(workflowName); | ||
} | ||
|
||
public static void LogActivityName(string activityName) | ||
{ | ||
registeredActivities.Add(activityName); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters