Skip to content

Commit

Permalink
add more detailed tracing logs in the hope that knowing the trace IDs…
Browse files Browse the repository at this point in the history
… will help us find the traces in X-Ray
  • Loading branch information
bpholt committed Dec 6, 2023
1 parent 2523c49 commit 3f6ee3f
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import com.dwolla.aws.sns.*
import feral.lambda.events.SnsEvent
import feral.lambda.{INothing, LambdaEnv}
import fs2.Stream
import natchez.{EntryPoint, Span}
import natchez.{EntryPoint, Span, Trace}
import natchez.mtl.given
import org.typelevel.log4cats.{Logger, LoggerFactory}
import com.dwolla.tracing.syntax.*

Expand All @@ -18,15 +19,19 @@ object LifecycleHookHandler {
(eventBridge: (TopicARN, LifecycleHookNotification) => F[Unit])
(using fs2.Compiler[F, F], Local[F, Span[F]]): LambdaEnv[F, SnsEvent] => F[Option[INothing]] = env =>
entryPoint.runInRoot(hookName) {
Stream.eval(env.event)
.map(_.records)
.flatMap(Stream.emits(_))
.map(_.sns)
.evalMap(ParseLifecycleHookNotification[F])
.unNone
.evalMap(eventBridge.tupled)
.compile
.drain
.as(None)
Trace[F].kernel.flatMap(k => Logger[F].info(s"trace kernel: ${k.toHeaders}")) >>
Stream.eval(env.event)
.map(_.records)
.flatMap(Stream.emits(_))
.map(_.sns)
.evalMap(ParseLifecycleHookNotification[F])
.unNone
.evalMap(eventBridge.tupled)
.compile
.drain
.as(None)
}
.flatTap { _ =>
Logger[F].info("tracing should be complete by now")
}
}

0 comments on commit 3f6ee3f

Please sign in to comment.