Add stream name to buffer overflow log message (#28159)
* Add stream name to buffer overflow log message (#28085) * De-emphasize stream name by moving it to the back Co-authored-by: Arnout Engelen <github@bzzt.net>
This commit is contained in:
parent
6278968af5
commit
e182c5a1fc
3 changed files with 73 additions and 25 deletions
|
|
@ -52,6 +52,7 @@ private object ActorRefSource {
|
||||||
override protected def stageActorName: String =
|
override protected def stageActorName: String =
|
||||||
inheritedAttributes.get[Attributes.Name].map(_.n).getOrElse(super.stageActorName)
|
inheritedAttributes.get[Attributes.Name].map(_.n).getOrElse(super.stageActorName)
|
||||||
|
|
||||||
|
private val name = inheritedAttributes.nameOrDefault(getClass.toString)
|
||||||
override val ref: ActorRef = getEagerStageActor(eagerMaterializer, poisonPillCompatibility = true) {
|
override val ref: ActorRef = getEagerStageActor(eagerMaterializer, poisonPillCompatibility = true) {
|
||||||
case (_, PoisonPill) =>
|
case (_, PoisonPill) =>
|
||||||
log.warning(
|
log.warning(
|
||||||
|
|
@ -71,19 +72,23 @@ private object ActorRefSource {
|
||||||
buffer match {
|
buffer match {
|
||||||
case OptionVal.None =>
|
case OptionVal.None =>
|
||||||
if (isCompleting) {
|
if (isCompleting) {
|
||||||
log.warning("Dropping element because Status.Success received already: [{}]", m)
|
log.warning("Dropping element because Status.Success received already: [{}] in stream [{}]", m, name)
|
||||||
} else if (isAvailable(out)) {
|
} else if (isAvailable(out)) {
|
||||||
push(out, m)
|
push(out, m)
|
||||||
} else {
|
} else {
|
||||||
log.debug("Dropping element because there is no downstream demand and no buffer: [{}]", m)
|
log.debug(
|
||||||
|
"Dropping element because there is no downstream demand and no buffer: [{}] in stream [{}]",
|
||||||
|
m,
|
||||||
|
name)
|
||||||
}
|
}
|
||||||
|
|
||||||
case OptionVal.Some(buf) =>
|
case OptionVal.Some(buf) =>
|
||||||
if (isCompleting) {
|
if (isCompleting) {
|
||||||
log.warning(
|
log.warning(
|
||||||
"Dropping element because Status.Success received already, only draining already buffered elements: [{}] (pending: [{}])",
|
"Dropping element because Status.Success received already, only draining already buffered elements: [{}] (pending: [{}] in stream [{}])",
|
||||||
m,
|
m,
|
||||||
buf.used)
|
buf.used,
|
||||||
|
name)
|
||||||
} else if (!buf.isFull) {
|
} else if (!buf.isFull) {
|
||||||
buf.enqueue(m)
|
buf.enqueue(m)
|
||||||
tryPush()
|
tryPush()
|
||||||
|
|
@ -92,30 +97,37 @@ private object ActorRefSource {
|
||||||
case s: DropHead =>
|
case s: DropHead =>
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping the head element because buffer is full and overflowStrategy is: [DropHead]")
|
"Dropping the head element because buffer is full and overflowStrategy is: [DropHead] in stream [{}]",
|
||||||
|
name)
|
||||||
buf.dropHead()
|
buf.dropHead()
|
||||||
buf.enqueue(m)
|
buf.enqueue(m)
|
||||||
tryPush()
|
tryPush()
|
||||||
case s: DropTail =>
|
case s: DropTail =>
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping the tail element because buffer is full and overflowStrategy is: [DropTail]")
|
"Dropping the tail element because buffer is full and overflowStrategy is: [DropTail] in stream [{}]",
|
||||||
|
name)
|
||||||
buf.dropTail()
|
buf.dropTail()
|
||||||
buf.enqueue(m)
|
buf.enqueue(m)
|
||||||
tryPush()
|
tryPush()
|
||||||
case s: DropBuffer =>
|
case s: DropBuffer =>
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping all the buffered elements because buffer is full and overflowStrategy is: [DropBuffer]")
|
"Dropping all the buffered elements because buffer is full and overflowStrategy is: [DropBuffer] in stream [{}]",
|
||||||
|
name)
|
||||||
buf.clear()
|
buf.clear()
|
||||||
buf.enqueue(m)
|
buf.enqueue(m)
|
||||||
tryPush()
|
tryPush()
|
||||||
case s: DropNew =>
|
case s: DropNew =>
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping the new element because buffer is full and overflowStrategy is: [DropNew]")
|
"Dropping the new element because buffer is full and overflowStrategy is: [DropNew] in stream [{}]",
|
||||||
|
name)
|
||||||
case s: Fail =>
|
case s: Fail =>
|
||||||
log.log(s.logLevel, "Failing because buffer is full and overflowStrategy is: [Fail]")
|
log.log(
|
||||||
|
s.logLevel,
|
||||||
|
"Failing because buffer is full and overflowStrategy is: [Fail] in stream [{}]",
|
||||||
|
name)
|
||||||
val bufferOverflowException =
|
val bufferOverflowException =
|
||||||
BufferOverflowException(s"Buffer overflow (max capacity was: $maxBuffer)!")
|
BufferOverflowException(s"Buffer overflow (max capacity was: $maxBuffer)!")
|
||||||
failStage(bufferOverflowException)
|
failStage(bufferOverflowException)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import scala.concurrent.{ Future, Promise }
|
||||||
|
|
||||||
override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
|
override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
|
||||||
val completion = Promise[Done]
|
val completion = Promise[Done]
|
||||||
|
val name = inheritedAttributes.nameOrDefault(getClass.toString)
|
||||||
|
|
||||||
val stageLogic = new GraphStageLogic(shape) with OutHandler with SourceQueueWithComplete[T] with StageLogging {
|
val stageLogic = new GraphStageLogic(shape) with OutHandler with SourceQueueWithComplete[T] with StageLogging {
|
||||||
override protected def logSource: Class[_] = classOf[QueueSource[_]]
|
override protected def logSource: Class[_] = classOf[QueueSource[_]]
|
||||||
|
|
@ -65,32 +66,41 @@ import scala.concurrent.{ Future, Promise }
|
||||||
case s: DropHead =>
|
case s: DropHead =>
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping the head element because buffer is full and overflowStrategy is: [DropHead]")
|
"Dropping the head element because buffer is full and overflowStrategy is: [DropHead] in stream [{}]",
|
||||||
|
name)
|
||||||
buffer.dropHead()
|
buffer.dropHead()
|
||||||
enqueueAndSuccess(offer)
|
enqueueAndSuccess(offer)
|
||||||
case s: DropTail =>
|
case s: DropTail =>
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping the tail element because buffer is full and overflowStrategy is: [DropTail]")
|
"Dropping the tail element because buffer is full and overflowStrategy is: [DropTail] in stream [{}]",
|
||||||
|
name)
|
||||||
buffer.dropTail()
|
buffer.dropTail()
|
||||||
enqueueAndSuccess(offer)
|
enqueueAndSuccess(offer)
|
||||||
case s: DropBuffer =>
|
case s: DropBuffer =>
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping all the buffered elements because buffer is full and overflowStrategy is: [DropBuffer]")
|
"Dropping all the buffered elements because buffer is full and overflowStrategy is: [DropBuffer] in stream [{}]",
|
||||||
|
name)
|
||||||
buffer.clear()
|
buffer.clear()
|
||||||
enqueueAndSuccess(offer)
|
enqueueAndSuccess(offer)
|
||||||
case s: DropNew =>
|
case s: DropNew =>
|
||||||
log.log(s.logLevel, "Dropping the new element because buffer is full and overflowStrategy is: [DropNew]")
|
log.log(
|
||||||
|
s.logLevel,
|
||||||
|
"Dropping the new element because buffer is full and overflowStrategy is: [DropNew] in stream [{}]",
|
||||||
|
name)
|
||||||
offer.promise.success(QueueOfferResult.Dropped)
|
offer.promise.success(QueueOfferResult.Dropped)
|
||||||
case s: Fail =>
|
case s: Fail =>
|
||||||
log.log(s.logLevel, "Failing because buffer is full and overflowStrategy is: [Fail]")
|
log.log(s.logLevel, "Failing because buffer is full and overflowStrategy is: [Fail] in stream [{}]", name)
|
||||||
val bufferOverflowException = BufferOverflowException(s"Buffer overflow (max capacity was: $maxBuffer)!")
|
val bufferOverflowException = BufferOverflowException(s"Buffer overflow (max capacity was: $maxBuffer)!")
|
||||||
offer.promise.success(QueueOfferResult.Failure(bufferOverflowException))
|
offer.promise.success(QueueOfferResult.Failure(bufferOverflowException))
|
||||||
completion.failure(bufferOverflowException)
|
completion.failure(bufferOverflowException)
|
||||||
failStage(bufferOverflowException)
|
failStage(bufferOverflowException)
|
||||||
case s: Backpressure =>
|
case s: Backpressure =>
|
||||||
log.log(s.logLevel, "Backpressuring because buffer is full and overflowStrategy is: [Backpressure]")
|
log.log(
|
||||||
|
s.logLevel,
|
||||||
|
"Backpressuring because buffer is full and overflowStrategy is: [Backpressure] in stream [{}]",
|
||||||
|
name)
|
||||||
pendingOffer match {
|
pendingOffer match {
|
||||||
case Some(_) =>
|
case Some(_) =>
|
||||||
offer.promise.failure(
|
offer.promise.failure(
|
||||||
|
|
@ -118,21 +128,35 @@ import scala.concurrent.{ Future, Promise }
|
||||||
else
|
else
|
||||||
overflowStrategy match {
|
overflowStrategy match {
|
||||||
case s @ (_: DropHead | _: DropBuffer) =>
|
case s @ (_: DropHead | _: DropBuffer) =>
|
||||||
log.log(s.logLevel, "Dropping element because buffer is full and overflowStrategy is: [{}]", s)
|
log.log(
|
||||||
|
s.logLevel,
|
||||||
|
"Dropping element because buffer is full and overflowStrategy is: [{}] in stream [{}]",
|
||||||
|
s,
|
||||||
|
name)
|
||||||
pendingOffer.get.promise.success(QueueOfferResult.Dropped)
|
pendingOffer.get.promise.success(QueueOfferResult.Dropped)
|
||||||
pendingOffer = Some(offer)
|
pendingOffer = Some(offer)
|
||||||
case s @ (_: DropTail | _: DropNew) =>
|
case s @ (_: DropTail | _: DropNew) =>
|
||||||
log.log(s.logLevel, "Dropping element because buffer is full and overflowStrategy is: [{}]", s)
|
log.log(
|
||||||
|
s.logLevel,
|
||||||
|
"Dropping element because buffer is full and overflowStrategy is: [{}] in stream [{}]",
|
||||||
|
s,
|
||||||
|
name)
|
||||||
promise.success(QueueOfferResult.Dropped)
|
promise.success(QueueOfferResult.Dropped)
|
||||||
case s: Fail =>
|
case s: Fail =>
|
||||||
log.log(s.logLevel, "Failing because buffer is full and overflowStrategy is: [Fail]")
|
log.log(
|
||||||
|
s.logLevel,
|
||||||
|
"Failing because buffer is full and overflowStrategy is: [Fail] in stream [{}]",
|
||||||
|
name)
|
||||||
val bufferOverflowException =
|
val bufferOverflowException =
|
||||||
BufferOverflowException(s"Buffer overflow (max capacity was: $maxBuffer)!")
|
BufferOverflowException(s"Buffer overflow (max capacity was: $maxBuffer)!")
|
||||||
promise.success(QueueOfferResult.Failure(bufferOverflowException))
|
promise.success(QueueOfferResult.Failure(bufferOverflowException))
|
||||||
completion.failure(bufferOverflowException)
|
completion.failure(bufferOverflowException)
|
||||||
failStage(bufferOverflowException)
|
failStage(bufferOverflowException)
|
||||||
case s: Backpressure =>
|
case s: Backpressure =>
|
||||||
log.log(s.logLevel, "Failing because buffer is full and overflowStrategy is: [Backpressure]")
|
log.log(
|
||||||
|
s.logLevel,
|
||||||
|
"Failing because buffer is full and overflowStrategy is: [Backpressure] in stream [{}]",
|
||||||
|
name)
|
||||||
promise.failure(
|
promise.failure(
|
||||||
new IllegalStateException(
|
new IllegalStateException(
|
||||||
"You have to wait for previous offer to be resolved to send another request"))
|
"You have to wait for previous offer to be resolved to send another request"))
|
||||||
|
|
|
||||||
|
|
@ -909,6 +909,7 @@ private[stream] object Collect {
|
||||||
|
|
||||||
private val buffer: BufferImpl[T] = BufferImpl(size, inheritedAttributes)
|
private val buffer: BufferImpl[T] = BufferImpl(size, inheritedAttributes)
|
||||||
|
|
||||||
|
private val name = inheritedAttributes.nameOrDefault(getClass.toString)
|
||||||
val enqueueAction: T => Unit =
|
val enqueueAction: T => Unit =
|
||||||
overflowStrategy match {
|
overflowStrategy match {
|
||||||
case s: DropHead =>
|
case s: DropHead =>
|
||||||
|
|
@ -916,7 +917,8 @@ private[stream] object Collect {
|
||||||
if (buffer.isFull) {
|
if (buffer.isFull) {
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping the head element because buffer is full and overflowStrategy is: [DropHead]")
|
"Dropping the head element because buffer is full and overflowStrategy is: [DropHead] in stream [{}]",
|
||||||
|
name)
|
||||||
buffer.dropHead()
|
buffer.dropHead()
|
||||||
}
|
}
|
||||||
buffer.enqueue(elem)
|
buffer.enqueue(elem)
|
||||||
|
|
@ -926,7 +928,8 @@ private[stream] object Collect {
|
||||||
if (buffer.isFull) {
|
if (buffer.isFull) {
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping the tail element because buffer is full and overflowStrategy is: [DropTail]")
|
"Dropping the tail element because buffer is full and overflowStrategy is: [DropTail] in stream [{}]",
|
||||||
|
name)
|
||||||
buffer.dropTail()
|
buffer.dropTail()
|
||||||
}
|
}
|
||||||
buffer.enqueue(elem)
|
buffer.enqueue(elem)
|
||||||
|
|
@ -936,7 +939,8 @@ private[stream] object Collect {
|
||||||
if (buffer.isFull) {
|
if (buffer.isFull) {
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping all the buffered elements because buffer is full and overflowStrategy is: [DropBuffer]")
|
"Dropping all the buffered elements because buffer is full and overflowStrategy is: [DropBuffer] in stream [{}]",
|
||||||
|
name)
|
||||||
buffer.clear()
|
buffer.clear()
|
||||||
}
|
}
|
||||||
buffer.enqueue(elem)
|
buffer.enqueue(elem)
|
||||||
|
|
@ -947,17 +951,25 @@ private[stream] object Collect {
|
||||||
else
|
else
|
||||||
log.log(
|
log.log(
|
||||||
s.logLevel,
|
s.logLevel,
|
||||||
"Dropping the new element because buffer is full and overflowStrategy is: [DropNew]")
|
"Dropping the new element because buffer is full and overflowStrategy is: [DropNew] in stream [{}]",
|
||||||
|
name)
|
||||||
pull(in)
|
pull(in)
|
||||||
case s: Backpressure =>
|
case s: Backpressure =>
|
||||||
elem =>
|
elem =>
|
||||||
buffer.enqueue(elem)
|
buffer.enqueue(elem)
|
||||||
if (!buffer.isFull) pull(in)
|
if (!buffer.isFull) pull(in)
|
||||||
else log.log(s.logLevel, "Backpressuring because buffer is full and overflowStrategy is: [Backpressure]")
|
else
|
||||||
|
log.log(
|
||||||
|
s.logLevel,
|
||||||
|
"Backpressuring because buffer is full and overflowStrategy is: [Backpressure] in stream [{}]",
|
||||||
|
name)
|
||||||
case s: Fail =>
|
case s: Fail =>
|
||||||
elem =>
|
elem =>
|
||||||
if (buffer.isFull) {
|
if (buffer.isFull) {
|
||||||
log.log(s.logLevel, "Failing because buffer is full and overflowStrategy is: [Fail]")
|
log.log(
|
||||||
|
s.logLevel,
|
||||||
|
"Failing because buffer is full and overflowStrategy is: [Fail] in stream [{}]",
|
||||||
|
name)
|
||||||
failStage(BufferOverflowException(s"Buffer overflow (max capacity was: $size)!"))
|
failStage(BufferOverflowException(s"Buffer overflow (max capacity was: $size)!"))
|
||||||
} else {
|
} else {
|
||||||
buffer.enqueue(elem)
|
buffer.enqueue(elem)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue