Skip to content

Commit

Permalink
chore(#1): added performance logging example
Browse files Browse the repository at this point in the history
  • Loading branch information
snovak7 committed Jul 6, 2024
1 parent d4b4c0d commit 74a68d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions test/Worker/Migrations/M1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,28 @@ namespace InfinityFlow.Temporal.Migrator.Worker.Migrations;
/// M1.
/// </summary>
[Migration(1)]
public class M1 : IMigration
public partial class M1 : IMigration
{
private readonly ILogger _logger = Workflow.Logger;

/// <inheritdoc />
public ValueTask ExecuteAsync(CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();

Workflow.Logger.LogInformation("In M1 - {InWorkflow}", Workflow.InWorkflow);
LogM1(Workflow.InWorkflow);
if (!Workflow.InWorkflow)
{
throw new InvalidOperationException("Not in workflow");
}

return ValueTask.CompletedTask;
}

[LoggerMessage(
EventId = 0,
EventName = "M1",
Level = LogLevel.Information,
Message = "In M1 - {inWorkflow}")]
private partial void LogM1(bool inWorkflow);
}
13 changes: 11 additions & 2 deletions test/Worker/Migrations/M2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ namespace InfinityFlow.Temporal.Migrator.Worker.Migrations;
/// M2.
/// </summary>
[Migration(2)]
public class M2 : IMigration
public partial class M2 : IMigration
{
private readonly ILogger _logger = Workflow.Logger;

/// <inheritdoc />
public ValueTask ExecuteAsync(CancellationToken cancellationToken)
{
Workflow.Logger.LogInformation("In M2");
LogM2();
return ValueTask.CompletedTask;
}

[LoggerMessage(
EventId = 0,
EventName = "M2",
Level = LogLevel.Information,
Message = "In M2")]
private partial void LogM2();
}

0 comments on commit 74a68d5

Please sign in to comment.