Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update natchez-tagless to 0.2.5 to take advantage of best-effort tracing #142

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}