Skip to content

Commit

Permalink
Update natchez-tagless to 0.2.5 to take advantage of best-effort tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
bpholt committed Dec 4, 2023
1 parent e6e1e9c commit 18d3949
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

0 comments on commit 18d3949

Please sign in to comment.