Skip to content
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
42 changes: 7 additions & 35 deletions docs/guide/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,44 +77,16 @@ Wolverine's node agent controller performs health checks periodically (every 10

You can control this tracing behavior through the `DurabilitySettings`:

<!-- snippet: sample_using_Wolverine_Logging_attribute -->
<a id='snippet-sample_using_wolverine_logging_attribute'></a>
<!-- snippet: sample_configuring_health_check_tracing -->
<a id='snippet-sample_configuring_health_check_tracing'></a>
```cs
public record QuietMessage;

public record VerboseMessage;
// Disable the "wolverine_node_assignments" traces entirely
opts.Durability.NodeAssignmentHealthCheckTracingEnabled = false;

public class QuietAndVerboseMessageHandler
{
[WolverineLogging(
telemetryEnabled:false,
successLogLevel: LogLevel.None,
executionLogLevel:LogLevel.Trace)]
public void Handle(QuietMessage message)
{
Console.WriteLine("Hush!");
}

[WolverineLogging(
// Enable Open Telemetry tracing
TelemetryEnabled = true,

// Log on successful completion of this message
SuccessLogLevel = LogLevel.Information,

// Log on execution being complete, but before Wolverine does its own book keeping
ExecutionLogLevel = LogLevel.Information,

// Throw in yet another contextual logging statement
// at the beginning of message execution
MessageStartingLevel = LogLevel.Debug)]
public void Handle(VerboseMessage message)
{
Console.WriteLine("Tell me about it!");
}
}
// Or, sample those traces to only once every 10 minutes
// opts.Durability.NodeAssignmentHealthCheckTraceSamplingPeriod = TimeSpan.FromMinutes(10);
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Testing/CoreTests/Acceptance/logging_configuration.cs#L78-L114' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_wolverine_logging_attribute' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Testing/OpenTelemetry/OtelWebApiWolverineMarten/Program.cs#L18-L24' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_configuring_health_check_tracing' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## Controlling Message Specific Logging and Tracing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
opts.Policies.AutoApplyTransactions();
opts.CodeGeneration.TypeLoadMode = !builder.Environment.IsDevelopment() ? TypeLoadMode.Static : TypeLoadMode.Auto;

#region sample_configuring_health_check_tracing
// Disable the "wolverine_node_assignments" traces entirely
opts.Durability.NodeAssignmentHealthCheckTracingEnabled = false;

// Or, sample those traces to only once every 10 minutes
// opts.Durability.NodeAssignmentHealthCheckTraceSamplingPeriod = TimeSpan.FromMinutes(10);
#endregion
});

builder.Services.AddMarten(opts => { opts.Connection("host=localhost;Port=5433;Database=postgres;Username=postgres;password=postgres"); })
Expand Down