Skip to content

Commit

Permalink
Kubediag (#1995)
Browse files Browse the repository at this point in the history
* Rename logging template placeholders
  • Loading branch information
rogeralsing authored May 11, 2023
1 parent 17781b8 commit 9200268
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 34 deletions.
6 changes: 6 additions & 0 deletions benchmarks/KubernetesDiagnostics/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public static async Task Main()
await system
.Cluster()
.StartMemberAsync();

system.Shutdown.Register(() =>
{
Console.WriteLine("Shutting down...");
Environment.Exit(0);
});

var props = Props.FromFunc(ctx => Task.CompletedTask);
system.Root.SpawnNamed(props, "dummy");
Expand Down
18 changes: 9 additions & 9 deletions src/Proto.Actor/Context/ActorLoggingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override async Task Receive(MessageEnvelope envelope)

if (logLevel != LogLevel.None && _logger.IsEnabled(logLevel))
{
_logger.Log(logLevel, "Actor {Self} {ActorType} received message {MessageType}:{Message} from {Sender}",
_logger.Log(logLevel, "Actor {Self} {ActorType} received message {MessageType}:{MessagePayload} from {Sender}",
Self, ActorType, message.GetMessageTypeName(),
message,
SenderOrNone(envelope)
Expand All @@ -61,7 +61,7 @@ public override async Task Receive(MessageEnvelope envelope)
if (logLevel != LogLevel.None && _logger.IsEnabled(logLevel))
{
_logger.Log(logLevel,
"Actor {Self} {ActorType} completed message {MessageType}:{Message} from {Sender}", Self, ActorType,
"Actor {Self} {ActorType} completed message {MessageType}:{MessagePayload} from {Sender}", Self, ActorType,
message.GetMessageTypeName(),
message,
SenderOrNone(envelope)
Expand All @@ -73,7 +73,7 @@ public override async Task Receive(MessageEnvelope envelope)
if (_exceptionLogLevel != LogLevel.None && _logger.IsEnabled(_exceptionLogLevel))
{
_logger.Log(_exceptionLogLevel, x,
"Actor {Self} {ActorType} failed during message {MessageType}:{Message} from {Sender}", Self,
"Actor {Self} {ActorType} failed during message {MessageType}:{MessagePayload} from {Sender}", Self,
ActorType,
message.GetMessageTypeName(), message,
SenderOrNone(envelope)
Expand Down Expand Up @@ -110,7 +110,7 @@ public override async Task<T> RequestAsync<T>(PID target, object message, Cancel
{
if (_logLevel != LogLevel.None && _logger.IsEnabled(_logLevel))
{
_logger.Log(_logLevel, "Actor {Self} {ActorType} Sending RequestAsync {MessageType}:{Message} to {Target}",
_logger.Log(_logLevel, "Actor {Self} {ActorType} Sending RequestAsync {MessageType}:{MessagePayload} to {Target}",
Self, ActorType,
message.GetMessageTypeName(), message, target
);
Expand All @@ -123,7 +123,7 @@ public override async Task<T> RequestAsync<T>(PID target, object message, Cancel
if (_logLevel != LogLevel.None && _logger.IsEnabled(_logLevel))
{
_logger.Log(_logLevel,
"Actor {Self} {ActorType} Got response {Response} to {MessageType}:{Message} from {Target}", Self,
"Actor {Self} {ActorType} Got response {Response} to {MessageType}:{MessagePayload} from {Target}", Self,
ActorType,
response, message.GetMessageTypeName(), message, target
);
Expand All @@ -136,7 +136,7 @@ public override async Task<T> RequestAsync<T>(PID target, object message, Cancel
if (_exceptionLogLevel != LogLevel.None && _logger.IsEnabled(_exceptionLogLevel))
{
_logger.Log(_exceptionLogLevel, x,
"Actor {Self} {ActorType} Got exception waiting for RequestAsync response of {MessageType}:{Message} from {Target}",
"Actor {Self} {ActorType} Got exception waiting for RequestAsync response of {MessageType}:{MessagePayload} from {Target}",
Self,
ActorType,
message.GetMessageTypeName(), message, target
Expand Down Expand Up @@ -195,7 +195,7 @@ public override void Respond(object message)

if (logLevel != LogLevel.None && _logger.IsEnabled(logLevel))
{
_logger.Log(logLevel, "Actor {Self} {ActorType} responded with {MessageType}:{Message} to {Sender}", Self,
_logger.Log(logLevel, "Actor {Self} {ActorType} responded with {MessageType}:{MessagePayload} to {Sender}", Self,
ActorType,
message.GetMessageTypeName(), message, Sender
);
Expand All @@ -218,7 +218,7 @@ public override void Request(PID target, object message, PID? sender)
{
if (_logLevel != LogLevel.None && _logger.IsEnabled(_logLevel))
{
_logger.Log(_logLevel, "Actor {Self} {ActorType} Sending Request {MessageType}:{Message} to {Target}",
_logger.Log(_logLevel, "Actor {Self} {ActorType} Sending Request {MessageType}:{MessagePayload} to {Target}",
Self, ActorType,
message.GetMessageTypeName(), message, target
);
Expand All @@ -231,7 +231,7 @@ public override void Send(PID target, object message)
{
if (_logLevel != LogLevel.None && _logger.IsEnabled(_logLevel))
{
_logger.Log(_logLevel, "Actor {Self} {ActorType} Sending {MessageType}:{Message} to {Target}", Self,
_logger.Log(_logLevel, "Actor {Self} {ActorType} Sending {MessageType}:{MessagePayload} to {Target}", Self,
ActorType,
message.GetMessageTypeName(), message, target
);
Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Actor/Context/DeadlineContextDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public override async Task Receive(MessageEnvelope envelope)

if (!ok)
{
_logger.LogWarning("Actor {Self} deadline {Deadline}, exceeded on message {Message}", _context.Self,
_logger.LogWarning("Actor {Self} deadline {Deadline}, exceeded on message {MessagePayload}", _context.Self,
_deadline, envelope.Message);

// keep waiting, we cannot just ignore and continue as an async task might still be running and updating state of the actor
Expand Down
12 changes: 6 additions & 6 deletions src/Proto.Actor/Context/RootLoggingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override void Send(PID target, object message)

if (logLevel != LogLevel.None && _logger.IsEnabled(logLevel))
{
_logger.Log(logLevel, "RootContext Sending {MessageType}:{Message} to {Target}", message.GetMessageTypeName(), message,
_logger.Log(logLevel, "RootContext Sending {MessageType}:{MessagePayload} to {Target}", message.GetMessageTypeName(), message,
target);
}

Expand All @@ -59,7 +59,7 @@ public override void Request(PID target, object message, PID? sender)

if (logLevel != LogLevel.None && _logger.IsEnabled(logLevel))
{
_logger.Log(logLevel, "Sending Request {MessageType}:{Message} to {Target}", message.GetMessageTypeName(),
_logger.Log(logLevel, "Sending Request {MessageType}:{MessagePayload} to {Target}", message.GetMessageTypeName(),
message, target);
}

Expand Down Expand Up @@ -137,7 +137,7 @@ public override void Request(PID target, object message)

if (logLevel != LogLevel.None && _logger.IsEnabled(logLevel))
{
_logger.Log(logLevel, "RootContext Sending Request {MessageType}:{Message} to {Target}", message.GetMessageTypeName(),
_logger.Log(logLevel, "RootContext Sending Request {MessageType}:{MessagePayload} to {Target}", message.GetMessageTypeName(),
message, target);
}

Expand All @@ -148,7 +148,7 @@ public override async Task<T> RequestAsync<T>(PID target, object message, Cancel
{
if (_logLevel != LogLevel.None && _logger.IsEnabled(_logLevel))
{
_logger.Log(_logLevel, "RootContext Sending RequestAsync {MessageType}:{Message} to {Target}",
_logger.Log(_logLevel, "RootContext Sending RequestAsync {MessageType}:{MessagePayload} to {Target}",
message.GetMessageTypeName(), message, target
);
}
Expand All @@ -160,7 +160,7 @@ public override async Task<T> RequestAsync<T>(PID target, object message, Cancel
if (_logLevel != LogLevel.None && _logger.IsEnabled(_logLevel))
{
_logger.Log(_logLevel,
"RootContext Got response {Response} to {MessageType}:{Message} from {Target}",
"RootContext Got response {Response} to {MessageType}:{MessagePayload} from {Target}",
response, message.GetMessageTypeName(), message, target
);
}
Expand All @@ -172,7 +172,7 @@ public override async Task<T> RequestAsync<T>(PID target, object message, Cancel
if (_exceptionLogLevel != LogLevel.None && _logger.IsEnabled(_exceptionLogLevel))
{
_logger.Log(_exceptionLogLevel, x,
"RootContext Got exception waiting for RequestAsync response of {MessageType}:{Message} from {Target}",
"RootContext Got exception waiting for RequestAsync response of {MessageType}:{MessagePayload} from {Target}",
message.GetMessageTypeName(), message, target
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Actor/Diagnostics/DiagnosticsStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void RegisterEvent(string module, string message)
var entry = new DiagnosticsEntry(module, message, null);
if (_entries.TryAdd(entry))
{
_logger.Log(_logLevel, "[Diagnostics] {Module}: {Message}", module, message);
_logger.Log(_logLevel, "[Diagnostics] {Module}: {MessagePayload}", module, message);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Actor/EventStream/EventStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal EventStream(ActorSystem system)
dl.Message is not IIgnoreDeadLetterLogging)
{
_logger.LogInformation(
"[DeadLetter] could not deliver '{MessageType}:{Message}' to '{Target}' from '{Sender}'",
"[DeadLetter] could not deliver '{MessageType}:{MessagePayload}' to '{Target}' from '{Sender}'",
dl.Message.GetMessageTypeName(),
dl.Message,
dl.Pid,
Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Cluster/Member/MemberList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public void BroadcastEvent(object message, bool includeSelf = true)
catch (Exception x)
{
x.CheckFailFast();
Logger.LogError(x, "[MemberList] Failed to broadcast {Message} to {Pid}", message, pid);
Logger.LogError(x, "[MemberList] Failed to broadcast {MessagePayload} to {Pid}", message, pid);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Proto.Remote/Endpoints/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void SendMessage(PID target, object msg)

if (_logger.IsEnabled(LogLevel.Trace))
{
_logger.LogTrace("[{SystemAddress}] Sending message {MessageType} {Message} to {Target} from {Sender}",
_logger.LogTrace("[{SystemAddress}] Sending message {MessageType} {MessagePayload} to {Target} from {Sender}",
System.Address,
message.GetMessageTypeName(), message, target, sender
);
Expand All @@ -115,7 +115,7 @@ public void SendMessage(PID target, object msg)

if (CancellationToken.IsCancellationRequested || !_remoteDelivers.Writer.TryWrite(env))
{
_logger.LogWarning("[{SystemAddress}] Dropping message {MessageType} {Message} to {Target} from {Sender}",
_logger.LogWarning("[{SystemAddress}] Dropping message {MessageType} {MessagePayload} to {Target} from {Sender}",
System.Address,
message.GetMessageTypeName(), message, target, sender
);
Expand Down Expand Up @@ -249,7 +249,7 @@ private int DropMessagesInBatch(RemoteMessage remoteMessage)
message = RemoteConfig.Serialization.Deserialize(typeName, envelope.MessageData,
envelope.SerializerId);

// _logger.LogDebug("Received (Type) {Message}", message.GetType(), message);
// _logger.LogDebug("Received (Type) {MessagePayload}", message.GetType(), message);

//translate from on-the-wire representation to in-process representation
//this only applies to root level messages, and never on nested child messages
Expand Down Expand Up @@ -468,14 +468,14 @@ private MessageBatch CreateBatch(IReadOnlyCollection<RemoteDeliver> m)
catch (CodedOutputStream.OutOfSpaceException oom)
{
System.Diagnostics.RegisterEvent("Remote", $"Message is too large {message.GetMessageTypeName()}");
_logger.LogError(oom, "Message is too large {Message}", message.GetMessageTypeName());
_logger.LogError(oom, "Message is too large {MessagePayload}", message.GetMessageTypeName());

throw;
}
catch (Exception x)
{
System.Diagnostics.RegisterEvent("Remote", $"Missing serializer for {message.GetMessageTypeName()}");
_logger.LogError(x, "Serialization failed for message {Message}", message.GetMessageTypeName());
_logger.LogError(x, "Serialization failed for message {MessagePayload}", message.GetMessageTypeName());

throw;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Proto.Remote/Endpoints/RemoteMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void HandleRemoteMessage(RemoteMessage currentMessage, string remoteAddre
if (_logger.IsEnabled(LogLevel.Trace))
{
_logger.LogTrace(
"[{SystemAddress}] Received message {MessageType} {Message} for {Target}",
"[{SystemAddress}] Received message {MessageType} {MessagePayload} for {Target}",
_system.Address,
msg.GetType().Name, msg, target
);
Expand All @@ -159,7 +159,7 @@ public void HandleRemoteMessage(RemoteMessage currentMessage, string remoteAddre
if (_logger.IsEnabled(LogLevel.Trace))
{
_logger.LogTrace(
"[{SystemAddress}] Received system message {MessageType} {Message} for {Target}",
"[{SystemAddress}] Received system message {MessageType} {MessagePayload} for {Target}",
_system.Address,
sys.GetType().Name, sys, target
);
Expand Down Expand Up @@ -190,7 +190,7 @@ public void HandleRemoteMessage(RemoteMessage currentMessage, string remoteAddre
if (_logger.IsEnabled(LogLevel.Trace))
{
_logger.LogTrace(
"[{SystemAddress}] Received user message {MessageType} {Message} for {Target} from {Sender}",
"[{SystemAddress}] Received user message {MessageType} {MessagePayload} for {Target} from {Sender}",
_system.Address, message.GetMessageTypeName(), message, target, sender
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Remote/Endpoints/ServerConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private Task StartReader(AsyncDuplexStreamingCall<RemoteMessage, RemoteMessage>
if (_connectorType == Type.ServerSide)
{
_logger.LogWarning(
"[ServerConnector][{SystemAddress}] Received {Message} from {Addres}",
"[ServerConnector][{SystemAddress}] Received {MessagePayload} from {Addres}",
_system.Address, currentMessage, _address);
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Remote/GrpcNet/GrpcNetClientRemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Task ShutdownAsync(bool graceful = true)
catch (Exception ex)
{
_logger.LogError(
ex, "Proto.Actor client {Id} stopped with error: {Message}",
ex, "Proto.Actor client {Id} stopped with error: {MessagePayload}",
System.Id, ex.Message
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Remote/GrpcNet/GrpcNetRemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public async Task ShutdownAsync(bool graceful = true)
catch (Exception ex)
{
_logger.LogError(
ex, "Proto.Actor server stopped on {Address} with error: {Message}",
ex, "Proto.Actor server stopped on {Address} with error: {MessagePayload}",
System.Address, ex.Message
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Remote/GrpcNet/HostedGrpcNetRemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Task ShutdownAsync(bool graceful = true)
catch (Exception ex)
{
_logger.LogError(
ex, "Proto.Actor server stopped on {Address} with error: {Message}",
ex, "Proto.Actor server stopped on {Address} with error: {MessagePayload}",
System.Address, ex.Message
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public static Func<Sender, Sender> Create(Func<Proto.MessageEnvelope, bool>? sho
}
catch (CodedOutputStream.OutOfSpaceException oom)
{
Logger.LogError(oom, "Message is too large for serialization {Message}", message?.GetType().Name);
Logger.LogError(oom, "Message is too large for serialization {MessagePayload}", message?.GetType().Name);
throw;
}
catch (Exception ex)
{
ex.CheckFailFast();
Logger.LogError(ex, "Forced serialization -> deserialization failed for message {Message}",
Logger.LogError(ex, "Forced serialization -> deserialization failed for message {MessagePayload}",
message?.GetType().Name);
throw;
Expand Down
2 changes: 1 addition & 1 deletion tests/Proto.Cluster.Tests/ClusterFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ protected virtual async Task<Cluster> SpawnClusterMember(Func<ClusterConfig, Clu

system.EventStream.Subscribe<object>(e =>
{
logger?.LogDebug("EventStream {MessageType}:{Message}", e.GetType().Name, e);
logger?.LogDebug("EventStream {MessageType}:{MessagePayload}", e.GetType().Name, e);
}
);

Expand Down

0 comments on commit 9200268

Please sign in to comment.