Skip to content

Commit

Permalink
hotfix(MetricReporting.scala): reportLagTime_on_empty_dataframe (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
Irenez753 authored Aug 9, 2020
1 parent 5a0e2cc commit 042a106
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/scala/com/yotpo/metorikku/metric/MetricReporting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ class MetricReporting {
def reportLagTime(dataFrame: DataFrame, reportLagTimeColumn: Option[String],
reportLagTimeColumnUnits:Option[String],
instrumentationProvider: InstrumentationProvider) : Unit ={
val maxDataframeTime = getMaxDataframeTime(dataFrame, reportLagTimeColumn, reportLagTimeColumnUnits)
log.info(s"Max column ${reportLagTimeColumn} value is ${maxDataframeTime} for ${dataFrame}")
val lag = System.currentTimeMillis - maxDataframeTime
log.info(s"Reporting lag value: ${lag} for ${dataFrame}")
instrumentationProvider.gauge(name = "lag", lag)
dataFrame.isEmpty match {
case false => {
val maxDataframeTime = getMaxDataframeTime(dataFrame, reportLagTimeColumn, reportLagTimeColumnUnits)
log.info(s"Max column ${reportLagTimeColumn} value is ${maxDataframeTime} for ${dataFrame}")
val lag = System.currentTimeMillis - maxDataframeTime
log.info(s"Reporting lag value: ${lag} for ${dataFrame}")
instrumentationProvider.gauge(name = "lag", lag)
}
case true => instrumentationProvider.gauge(name = "lag", 0)
}
}
}

0 comments on commit 042a106

Please sign in to comment.