Skip to content

Commit

Permalink
Merge pull request guardian#4364 from guardian/an/add-random-suffix-t…
Browse files Browse the repository at this point in the history
…o-actor-id

add random suffix to actor ID to ensure uniqueness
  • Loading branch information
andrew-nowak authored Nov 8, 2024
2 parents c2fcc38 + 19b2fcb commit 0ea47cb
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import java.util.Date
import scala.collection.JavaConverters._
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.duration.{DurationInt, FiniteDuration}
import scala.util.Random

trait Metric[A] {
def recordOne(value: A, dimensions: List[Dimension] = Nil): Unit
Expand Down Expand Up @@ -45,7 +46,8 @@ abstract class CloudWatchMetrics(

private val client: AmazonCloudWatch = config.withAWSCredentials(AmazonCloudWatchClientBuilder.standard()).build()

private[CloudWatchMetrics] val metricsActor = actorSystem.actorOf(MetricsActor.props(namespace, client), "metricsactor")
private val random = new Random()
private[CloudWatchMetrics] val metricsActor = actorSystem.actorOf(MetricsActor.props(namespace, client), s"metricsactor-${random.alphanumeric.take(8).mkString}")

applicationLifecycle.addStopHook(() => (metricsActor ? MetricsActor.Shutdown)(Timeout(5.seconds)))

Expand Down

0 comments on commit 0ea47cb

Please sign in to comment.