Skip to content

Commit 0a01453

Browse files
Make actor start / stop telemetry descriptors overrideable (#7434)
Designed to support petabridge/phobos-issues#82
1 parent 61bdebf commit 0a01453

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ namespace Akka.Actor
9494
public void CheckReceiveTimeout(bool reschedule = True) { }
9595
protected void ClearActor(Akka.Actor.ActorBase actor) { }
9696
protected void ClearActorCell() { }
97+
protected virtual Akka.Actor.ActorStarted CreateActorStartedEvent() { }
98+
protected virtual Akka.Actor.ActorStopped CreateActorStoppedEvent() { }
9799
protected virtual Akka.Actor.ActorBase CreateNewActorInstance() { }
98100
[System.ObsoleteAttribute("Use TryGetChildStatsByName [0.7.1]", true)]
99101
public Akka.Actor.IInternalActorRef GetChildByName(string name) { }

src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Net.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ namespace Akka.Actor
9494
public void CheckReceiveTimeout(bool reschedule = True) { }
9595
protected void ClearActor(Akka.Actor.ActorBase actor) { }
9696
protected void ClearActorCell() { }
97+
protected virtual Akka.Actor.ActorStarted CreateActorStartedEvent() { }
98+
protected virtual Akka.Actor.ActorStopped CreateActorStoppedEvent() { }
9799
protected virtual Akka.Actor.ActorBase CreateNewActorInstance() { }
98100
[System.ObsoleteAttribute("Use TryGetChildStatsByName [0.7.1]", true)]
99101
public Akka.Actor.IInternalActorRef GetChildByName(string name) { }

src/core/Akka/Actor/ActorCell.DefaultMessages.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,22 @@ public void Restart(Exception cause)
429429
SendSystemMessage(new Recreate(cause));
430430
}
431431

432+
/// <summary>
433+
/// Overrideable in order to support issues such as https://github.com/petabridge/phobos-issues/issues/82
434+
/// </summary>
435+
protected virtual ActorStarted CreateActorStartedEvent()
436+
{
437+
return new ActorStarted(Self, Props.Type);
438+
}
439+
440+
/// <summary>
441+
/// Overrideable in order to support issues such as https://github.com/petabridge/phobos-issues/issues/82
442+
/// </summary>
443+
protected virtual ActorStopped CreateActorStoppedEvent()
444+
{
445+
return new ActorStopped(Self, Props.Type);
446+
}
447+
432448
private void Create(Exception failure)
433449
{
434450
if (failure != null)
@@ -442,7 +458,7 @@ private void Create(Exception failure)
442458
if (System.Settings.DebugLifecycle)
443459
Publish(new Debug(Self.Path.ToString(), created.GetType(), "Started (" + created + ")"));
444460
if(System.Settings.EmitActorTelemetry)
445-
System.EventStream.Publish(new ActorStarted(Self, Props.Type));
461+
System.EventStream.Publish(CreateActorStartedEvent());
446462
}
447463
catch (Exception e)
448464
{

src/core/Akka/Actor/ActorCell.FaultHandling.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ private void FinishTerminate()
290290
}
291291

292292
if(System.Settings.EmitActorTelemetry)
293-
System.EventStream.Publish(new ActorStopped(Self, Props.Type));
293+
System.EventStream.Publish(CreateActorStoppedEvent());
294294
}
295295
catch (Exception x)
296296
{

0 commit comments

Comments
 (0)