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
|
|
@ -36,6 +36,7 @@ import scala.concurrent.{ Future, Promise }
|
|||
|
||||
override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
|
||||
val completion = Promise[Done]
|
||||
val name = inheritedAttributes.nameOrDefault(getClass.toString)
|
||||
|
||||
val stageLogic = new GraphStageLogic(shape) with OutHandler with SourceQueueWithComplete[T] with StageLogging {
|
||||
override protected def logSource: Class[_] = classOf[QueueSource[_]]
|
||||
|
|
@ -65,32 +66,41 @@ import scala.concurrent.{ Future, Promise }
|
|||
case s: DropHead =>
|
||||
log.log(
|
||||
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()
|
||||
enqueueAndSuccess(offer)
|
||||
case s: DropTail =>
|
||||
log.log(
|
||||
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()
|
||||
enqueueAndSuccess(offer)
|
||||
case s: DropBuffer =>
|
||||
log.log(
|
||||
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()
|
||||
enqueueAndSuccess(offer)
|
||||
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)
|
||||
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)!")
|
||||
offer.promise.success(QueueOfferResult.Failure(bufferOverflowException))
|
||||
completion.failure(bufferOverflowException)
|
||||
failStage(bufferOverflowException)
|
||||
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 {
|
||||
case Some(_) =>
|
||||
offer.promise.failure(
|
||||
|
|
@ -118,21 +128,35 @@ import scala.concurrent.{ Future, Promise }
|
|||
else
|
||||
overflowStrategy match {
|
||||
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 = Some(offer)
|
||||
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)
|
||||
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)!")
|
||||
promise.success(QueueOfferResult.Failure(bufferOverflowException))
|
||||
completion.failure(bufferOverflowException)
|
||||
failStage(bufferOverflowException)
|
||||
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(
|
||||
new IllegalStateException(
|
||||
"You have to wait for previous offer to be resolved to send another request"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue