From 3f6ee3f1e7470706c4fa79d60cabba3e20c589de Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Wed, 6 Dec 2023 16:49:53 -0600 Subject: [PATCH] add more detailed tracing logs in the hope that knowing the trace IDs will help us find the traces in X-Ray --- .../autoscaling/LifecycleHookHandler.scala | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/core/src/main/scala/com/dwolla/aws/autoscaling/LifecycleHookHandler.scala b/core/src/main/scala/com/dwolla/aws/autoscaling/LifecycleHookHandler.scala index 846f5ad..2e5afba 100644 --- a/core/src/main/scala/com/dwolla/aws/autoscaling/LifecycleHookHandler.scala +++ b/core/src/main/scala/com/dwolla/aws/autoscaling/LifecycleHookHandler.scala @@ -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.* @@ -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") + } }