Skip to content

Commit

Permalink
automatically create a group for sharing actors
Browse files Browse the repository at this point in the history
  • Loading branch information
ivantopo committed Jun 21, 2019
1 parent c159374 commit a05c944
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import java.util.concurrent.atomic.AtomicLong

import akka.actor.Actor
import kamon.instrumentation.akka.AkkaClusterShardingMetrics.ShardingInstruments
import kamon.instrumentation.akka.AkkaInstrumentation
import kamon.instrumentation.akka.instrumentations.VersionFiltering
import kamon.util.Filter
import kanela.agent.api.instrumentation.InstrumentationBuilder
import kanela.agent.libs.net.bytebuddy.asm.Advice

Expand Down Expand Up @@ -77,8 +79,15 @@ object HasShardCounters {
object InitializeShardRegionAdvice {

@Advice.OnMethodExit
def exit(@Advice.This region: Actor with HasShardingInstruments, @Advice.Argument(0) typeName: String): Unit =
def exit(@Advice.This region: Actor with HasShardingInstruments, @Advice.Argument(0) typeName: String): Unit = {
region.setShardingInstruments(new ShardingInstruments(region.context.system.name, typeName))

val system = region.context.system
val shardingGuardian = system.settings.config.getString("akka.cluster.sharding.guardian-name")
val entitiesPath = s"${system.name}/system/$shardingGuardian/$typeName/*/*"

AkkaInstrumentation.defineActorGroup(s"shardRegion/$typeName", Filter.fromGlob(entitiesPath))
}
}

object InitializeShardAdvice {
Expand Down

0 comments on commit a05c944

Please sign in to comment.