How can get the count of Active live actors?

120 Views Asked by At

I'm using akka cluster sharding 2.5.23. For my case i want to know the current live active actors count.I have read many articles saying use Lightbend telemetry which is paid.And Cinnamonor or kamon which i don't need that much of metrics.I only need to know current active actors. Any way to achieve this easy?

1

There are 1 best solutions below

0
On BEST ANSWER

As i'm using ActorCluster sharding with Remember entities as ddata,All the entityActors are remembered in distributed way. We have GetClusterShardingStats util get the sharding stats in that we will have the current shard count and actors count in that Cluster.

GetClusterShardingStats stats = new ShardRegion.GetClusterShardingStats(FiniteDuration.create(25000, TimeUnit.MILLISECONDS));
final Duration timeout = Duration.ofSeconds(25);
                Future<Object> ack = Patterns.ask(region, stats, timeout).toCompletableFuture();
                ClusterShardingStats ss = (ClusterShardingStats) ack.get(25000, TimeUnit.MILLISECONDS);
                

By iterating this ClusterShardingStats we can get the current Live Shard Count and Actors in that Shard count even with Node wise count.