| | 1 | | using System; |
| | 2 | | using System.Diagnostics; |
| | 3 | | using Akka.Actor; |
| | 4 | | using Akka.Actor.Internal; |
| | 5 | | using Akka.Dispatch; |
| | 6 | | using Akka.Dispatch.SysMsg; |
| | 7 | |
|
| | 8 | | namespace SeungYongShim.Akka.OpenTelemetry |
| | 9 | | { |
| | 10 | |
|
| | 11 | | public class TraceLocalActorRef : LocalActorRef |
| | 12 | | { |
| | 13 | | public TraceLocalActorRef(ActorSystemImpl system, |
| | 14 | | Props props, |
| | 15 | | MessageDispatcher dispatcher, |
| | 16 | | MailboxType mailboxType, |
| | 17 | | IInternalActorRef supervisor, |
| | 18 | | ActorPath path, |
| 4 | 19 | | Type actorTaskSchedulerMessageType) : base(system, props, dispatcher, mailboxType, sup |
| 4 | 20 | | { |
| 4 | 21 | | ActorTaskSchedulerMessageType = actorTaskSchedulerMessageType; |
| 4 | 22 | | } |
| | 23 | |
|
| | 24 | | public Type ActorTaskSchedulerMessageType { get; } |
| | 25 | | public TraceActorCell TraceActorCell { get; private set; } |
| | 26 | |
|
| | 27 | | public override void SendSystemMessage(ISystemMessage message) |
| 1 | 28 | | { |
| 1 | 29 | | if (ActorTaskSchedulerMessageType.IsInstanceOfType(message)) |
| 1 | 30 | | { |
| 1 | 31 | | if (ActorTaskSchedulerMessageType.GetProperty("Exception")? |
| 1 | 32 | | .GetValue(message) is Exception ex) |
| 1 | 33 | | { |
| 1 | 34 | | var m = ActorTaskSchedulerMessageType.GetProperty("Message")? |
| 1 | 35 | | .GetValue(message); |
| | 36 | |
|
| 1 | 37 | | message = (ISystemMessage)Activator.CreateInstance(ActorTaskSchedulerMessageType, |
| 1 | 38 | | new TraceException(ex), m); |
| | 39 | |
|
| 1 | 40 | | TraceActorCell.ActivityNew = Activity.Current?.Id; |
| 1 | 41 | | } |
| 1 | 42 | | } |
| | 43 | |
|
| 1 | 44 | | base.SendSystemMessage(message); |
| 1 | 45 | | } |
| | 46 | |
|
| | 47 | | protected override ActorCell NewActorCell(ActorSystemImpl system, IInternalActorRef self, Props props, |
| | 48 | | MessageDispatcher dispatcher, IInternalActorRef supervisor) |
| 4 | 49 | | { |
| 4 | 50 | | TraceActorCell = new TraceActorCell(system, self, props, dispatcher, supervisor); |
| 4 | 51 | | return TraceActorCell; |
| 4 | 52 | | } |
| | 53 | | } |
| | 54 | | } |