Skip to content

Commit

Permalink
Loader: Trim alert message payloads to 4096 characters (close #956)
Browse files Browse the repository at this point in the history
  • Loading branch information
pondzix authored and spenes committed Jul 4, 2022
1 parent dd7e315 commit a4690e8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ object Loader {
Logging.LoggerName(getClass.getSimpleName.stripSuffix("$"))

/** How often Loader should print its internal state */
val StateLoggingFrequency: FiniteDuration = 5.minutes
private val StateLoggingFrequency: FiniteDuration = 5.minutes

/** Restrict the length of an alert message to be compliant with alert iglu schema */
private val MaxAlertPayloadLength = 4096

/**
* Primary application's entry-point, responsible for launching all processes
Expand Down Expand Up @@ -182,7 +185,8 @@ object Loader {
case e: SQLException => s"${error.getMessage} - SqlState: ${e.getSQLState}"
case _ => Option(error.getMessage).getOrElse(error.toString)
}
val alert = Monitoring.AlertPayload.warn(message, discovery.origin.base)
val trimmedMessage = message.take(MaxAlertPayloadLength)
val alert = Monitoring.AlertPayload.warn(trimmedMessage, discovery.origin.base)
val logNoRetry = Logging[F].error(s"Loading of ${discovery.origin.base} has failed. Not adding into retry queue. $message")
val logRetry = Logging[F].error(s"Loading of ${discovery.origin.base} has failed. Adding intro retry queue. $message")

Expand Down

0 comments on commit a4690e8

Please sign in to comment.