Introduce onDeadLetterMailboxEnqueue hook for telemetry (#30279)

It's needed for better instrumentation stability in future versions.
This commit is contained in:
Yury Gribkov 2021-06-01 08:05:21 -04:00 committed by GitHub
parent 258bac491b
commit c31c114e7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,7 @@ import com.typesafe.config.{ Config, ConfigFactory }
import akka.ConfigurationException
import akka.actor.{ Actor, ActorRef, ActorSystem, DeadLetter, Deploy, DynamicAccess, Props }
import akka.annotation.InternalStableApi
import akka.dispatch.sysmsg.{
EarliestFirstSystemMessageList,
LatestFirstSystemMessageList,
@ -41,10 +42,7 @@ private[akka] class Mailboxes(
import Mailboxes._
val deadLetterMailbox: Mailbox = new Mailbox(new MessageQueue {
def enqueue(receiver: ActorRef, envelope: Envelope): Unit = envelope.message match {
case _: DeadLetter => // actor subscribing to DeadLetter, drop it
case msg => deadLetters.tell(DeadLetter(msg, envelope.sender, receiver), envelope.sender)
}
def enqueue(receiver: ActorRef, envelope: Envelope): Unit = onDeadLetterMailboxEnqueue(receiver, envelope)
def dequeue() = null
def hasMessages = false
def numberOfMessages = 0
@ -57,6 +55,12 @@ private[akka] class Mailboxes(
def hasSystemMessages = false
}
@InternalStableApi
private[akka] def onDeadLetterMailboxEnqueue(receiver: ActorRef, envelope: Envelope): Unit = envelope.message match {
case _: DeadLetter => // actor subscribing to DeadLetter, drop it
case msg => deadLetters.tell(DeadLetter(msg, envelope.sender, receiver), envelope.sender)
}
private val mailboxTypeConfigurators = new ConcurrentHashMap[String, MailboxType]
private val mailboxBindings: Map[Class[_ <: Any], String] = {