-
Notifications
You must be signed in to change notification settings - Fork 1
/
MonitorInterceptor.cs
46 lines (38 loc) · 1.34 KB
/
MonitorInterceptor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Akka.Actor;
using Akka.Monitoring.Impl;
using Castle.DynamicProxy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Akka.Monitoring;
namespace Akka.AOP.Monitoring
{
public class MonitorInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
try
{
Actor.ActorBase actorProxy = (Actor.ActorBase)invocation.Proxy;
IInternalActor internalActor = (IInternalActor)actorProxy;
IActorContext oontext = internalActor.ActorContext;
if (invocation.Method.Name.Equals("PreStart", StringComparison.InvariantCultureIgnoreCase))
{
oontext.IncrementActorCreated();
}
if (invocation.Method.Name.Equals("AroundReceive", StringComparison.InvariantCultureIgnoreCase))
{
oontext.IncrementMessagesReceived();
}
Console.WriteLine("{0} - {1}",invocation.TargetType.Name, invocation.Method.Name);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
invocation.Proceed();
}
}
}