Natchez integration for Lambda - #55
Conversation
| import feral.lambda.events.ApiGatewayProxyEventV2 | ||
| import natchez.Kernel | ||
|
|
||
| trait HasKernel[Event] { |
| object Tags { | ||
| private[this] val prefix = "aws" | ||
| def arn(s: String): (String, TraceValue) = s"$prefix.arn" -> s | ||
| def requestId(s: String): (String, TraceValue) = s"$prefix.requestId" -> s | ||
| } |
There was a problem hiding this comment.
IDK what I'm doing, does this do what we want? Any other tags to consider?
There was a problem hiding this comment.
This seems like a good start. I don't have enough experience using tags like this to anticipate wanting anything else.
| implicit val apiGateProxyResultV2KernelSink: KernelSink[ApiGatewayProxyResultV2] = { | ||
| case (result: ApiGatewayProxyStructuredResultV2, kernel) => | ||
| result.copy(headers = kernel.toHeaders ++ result.headers) | ||
| } |
There was a problem hiding this comment.
Oh wait, is this not a thing? I guess tracing headers don't really belong in a response 🙃
| object TracedLambda { | ||
|
|
||
| def apply[F[_]: MonadCancelThrow, Event: KernelSource, Result](entryPoint: EntryPoint[F])( | ||
| lambda: Span[F] => Lambda[F, Event, Result]): Lambda[F, Event, Result] = { |
There was a problem hiding this comment.
Given a parametric Lambda, wouldn't the better type here be something like Lambda[Kleisli[F, Span[F], *], Event, Result]? Could also bring in Cats MTL and do an Ask[F, Span[F]], though that starts to get odd.
There was a problem hiding this comment.
Not necessarily. natchez also supports tracing with IOLocal instead of Kleisli which IIUC is also more performant. I played with a few other ideas in #50. Also hoping that typelevel/natchez#448 becomes a thing.
There was a problem hiding this comment.
Oh btw, I now have an MTL lambda concept in #60. Actually this is my favorite so far, and I think http4s will be moving in this direction as well.
|
Integrated with #60, so it will merge in from there. |
Based on #51.