in notificationworkerlambda/src/main/scala/com/gu/notifications/worker/utils/Logging.scala [41:75]
def logInfo[A](prefix: String = ""): A => IO[Unit] = log(prefix, logger.info)
def logInfoWithFields[A](fields: Instant => Map[String, _], prefix: String = ""): A => IO[PerformanceMetrics] = logWithFields(fields, prefix, logger.info)
def logWarn[A](prefix: String = ""): A => IO[Unit] = log(prefix, logger.warn)
def logError[A](prefix: String = ""): A => IO[Unit] = log(prefix, logger.error)
def logFields(
env: Env,
notification: Notification,
numberOfTokens: Int,
sentTime: Long,
functionStartTime: Instant,
maybePlatform: Option[Platform],
sqsMessageBatchSize: Int,
messagingApi: String,
awsRequestId: String,
)(end: Instant): Map[String, Any] = {
val processingTime = Duration.between(functionStartTime, end).toMillis
val processingRate = numberOfTokens.toDouble / processingTime * 1000
val start = Instant.ofEpochMilli(sentTime)
Map(
"notificationId" -> notification.id,
"platform" -> maybePlatform.map(_.toString).getOrElse("unknown"),
"type" -> Reporting.notificationTypeForObservability(notification),
"worker.functionProcessingRate" -> processingRate,
"worker.functionProcessingTime" -> processingTime,
"worker.notificationProcessingTime" -> Duration.between(start, end).toMillis,
"worker.notificationProcessingStartTime.millis" -> sentTime,
"worker.notificationProcessingEndTime.millis" -> end.toEpochMilli,
"sqsMessageBatchSize" -> sqsMessageBatchSize,
"worker.chunkTokenSize" -> numberOfTokens,
"worker.messagingApi" -> messagingApi,
"awsRequestId" -> awsRequestId,
)
}