All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.touk.nussknacker.ui.metrics.TimeMeasuring.scala Maven / Gradle / Ivy

There is a newer version: 1.17.0
Show newest version
package pl.touk.nussknacker.ui.metrics

import io.dropwizard.metrics5.MetricRegistry

import scala.concurrent.{ExecutionContext, Future}

object TimeMeasuring extends TimeMeasuring

trait TimeMeasuring {

  def measureTime[T](name: String, metricRegistry: MetricRegistry)(
      action: => Future[T]
  )(implicit ec: ExecutionContext): Future[T] = {
    val ctx      = metricRegistry.timer(name).time()
    val toReturn = action
    toReturn.onComplete(_ => ctx.stop())
    toReturn
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy