From 18d394998f1825b2639497ad011e46b4f689fc68 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Mon, 4 Dec 2023 17:41:42 -0600 Subject: [PATCH] Update natchez-tagless to 0.2.5 to take advantage of best-effort tracing --- build.sbt | 2 +- .../dwolla/aws/autoscaling/LifecycleHookHandlerSpec.scala | 6 ++++-- .../com/dwolla/aws/autoscaling/LifecycleHookHandler.scala | 8 ++++---- .../ecs/draining/TerminationEventHandler.scala | 3 ++- .../ecs/registrator/ScaleOutPendingEventHandler.scala | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/build.sbt b/build.sbt index ba73332..9ba8830 100644 --- a/build.sbt +++ b/build.sbt @@ -70,7 +70,7 @@ lazy val `autoscaling-ecs-core`: Project = project "org.tpolecat" %% "natchez-core" % "0.3.4", "org.typelevel" %% "cats-tagless-core" % "0.15.0", "org.typelevel" %% "alleycats-core" % "2.10.0", - "com.dwolla" %% "natchez-tagless" % "0.2.4", + "com.dwolla" %% "natchez-tagless" % "0.2.5", ) }, ) diff --git a/core-tests/src/test/scala/com/dwolla/aws/autoscaling/LifecycleHookHandlerSpec.scala b/core-tests/src/test/scala/com/dwolla/aws/autoscaling/LifecycleHookHandlerSpec.scala index 7195901..9f0567e 100644 --- a/core-tests/src/test/scala/com/dwolla/aws/autoscaling/LifecycleHookHandlerSpec.scala +++ b/core-tests/src/test/scala/com/dwolla/aws/autoscaling/LifecycleHookHandlerSpec.scala @@ -14,8 +14,8 @@ import feral.lambda.events.SnsEvent import feral.lambda.{Context, ContextInstances, LambdaEnv} import munit.{CatsEffectSuite, ScalaCheckEffectSuite} import org.scalacheck.effect.PropF.forAllF -import org.typelevel.log4cats.LoggerFactory -import org.typelevel.log4cats.noop.NoOpFactory +import org.typelevel.log4cats.{Logger, LoggerFactory} +import org.typelevel.log4cats.noop.{NoOpFactory, NoOpLogger} import com.amazonaws.sns.TopicARN import com.dwolla.tracing.mtl.LocalSpan import natchez.Span @@ -27,6 +27,8 @@ class LifecycleHookHandlerSpec with ContextInstances { given LoggerFactory[IO] = NoOpFactory[IO] + given Logger[IO] = NoOpLogger[IO] + private def snsMessage[T: Encoder](topic: TopicARN, detail: T, maybeSubject: Option[String]): Json = json"""{ "Records": [ 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 09bb307..846f5ad 100644 --- a/core/src/main/scala/com/dwolla/aws/autoscaling/LifecycleHookHandler.scala +++ b/core/src/main/scala/com/dwolla/aws/autoscaling/LifecycleHookHandler.scala @@ -10,13 +10,13 @@ import feral.lambda.events.SnsEvent import feral.lambda.{INothing, LambdaEnv} import fs2.Stream import natchez.{EntryPoint, Span} -import org.typelevel.log4cats.LoggerFactory +import org.typelevel.log4cats.{Logger, LoggerFactory} import com.dwolla.tracing.syntax.* object LifecycleHookHandler { - def apply[F[_] : MonadCancelThrow : LoggerFactory](entryPoint: EntryPoint[F], hookName: String) - (eventBridge: (TopicARN, LifecycleHookNotification) => F[Unit]) - (using fs2.Compiler[F, F], Local[F, Span[F]]): LambdaEnv[F, SnsEvent] => F[Option[INothing]] = env => + def apply[F[_] : MonadCancelThrow : LoggerFactory : Logger](entryPoint: EntryPoint[F], hookName: String) + (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) diff --git a/draining/src/main/scala/com/dwolla/autoscaling/ecs/draining/TerminationEventHandler.scala b/draining/src/main/scala/com/dwolla/autoscaling/ecs/draining/TerminationEventHandler.scala index b34e409..c349e01 100644 --- a/draining/src/main/scala/com/dwolla/autoscaling/ecs/draining/TerminationEventHandler.scala +++ b/draining/src/main/scala/com/dwolla/autoscaling/ecs/draining/TerminationEventHandler.scala @@ -18,7 +18,7 @@ import natchez.Span import natchez.mtl.given import natchez.xray.XRay import org.http4s.ember.client.EmberClientBuilder -import org.typelevel.log4cats.LoggerFactory +import org.typelevel.log4cats.{Logger, LoggerFactory} import org.typelevel.log4cats.slf4j.Slf4jFactory import smithy4s.aws.* import smithy4s.aws.kernel.AwsRegion @@ -37,5 +37,6 @@ class TerminationEventHandler extends IOLambda[SnsEvent, INothing] { sns <- AwsClient(SNS, awsEnv).map(SnsAlg[IO](_).traceWithInputs) autoscaling = AutoScalingAlg[IO](autoscalingClient, sns).traceWithInputs bridgeFunction = TerminationEventBridge(ecs, autoscaling) + given Logger[IO] <- LoggerFactory[IO].create.toResource } yield LifecycleHookHandler(entryPoint, "TerminationEventHandler")(bridgeFunction) } diff --git a/registrator-health-check/src/main/scala/com/dwolla/autoscaling/ecs/registrator/ScaleOutPendingEventHandler.scala b/registrator-health-check/src/main/scala/com/dwolla/autoscaling/ecs/registrator/ScaleOutPendingEventHandler.scala index b70305d..40334f9 100644 --- a/registrator-health-check/src/main/scala/com/dwolla/autoscaling/ecs/registrator/ScaleOutPendingEventHandler.scala +++ b/registrator-health-check/src/main/scala/com/dwolla/autoscaling/ecs/registrator/ScaleOutPendingEventHandler.scala @@ -22,7 +22,7 @@ import natchez.mtl.given import natchez.xray.XRay import natchez.Span import org.http4s.ember.client.EmberClientBuilder -import org.typelevel.log4cats.LoggerFactory +import org.typelevel.log4cats.{Logger, LoggerFactory} import org.typelevel.log4cats.slf4j.Slf4jFactory import smithy4s.aws.* import smithy4s.aws.kernel.AwsRegion @@ -43,5 +43,6 @@ class ScaleOutPendingEventHandler extends IOLambda[SnsEvent, INothing] { cloudformationClient <- AwsClient(CloudFormation, awsEnv).map(CloudFormationAlg[IO](_)) autoscaling = AutoScalingAlg[IO](autoscalingClient, sns) bridgeFunction = ScaleOutPendingEventBridge(ecs, autoscaling, ec2Client, cloudformationClient) + given Logger[IO] <- LoggerFactory[IO].create.toResource } yield LifecycleHookHandler(entryPoint, "ScaleOutPendingEventHandler")(bridgeFunction) }