Skip to content

Natchez integration for Lambda - #55

Closed
armanbilge wants to merge 16 commits into
typelevel:mainfrom
armanbilge:topic/traced-lambda
Closed

Natchez integration for Lambda#55
armanbilge wants to merge 16 commits into
typelevel:mainfrom
armanbilge:topic/traced-lambda

Conversation

@armanbilge

Copy link
Copy Markdown
Member

Based on #51.

import feral.lambda.events.ApiGatewayProxyEventV2
import natchez.Kernel

trait HasKernel[Event] {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚲 🏠

Comment on lines +21 to +25
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
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK what I'm doing, does this do what we want? Any other tags to consider?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good start. I don't have enough experience using tags like this to anticipate wanting anything else.

@armanbilge armanbilge mentioned this pull request Nov 19, 2021
Comment on lines +48 to +51
implicit val apiGateProxyResultV2KernelSink: KernelSink[ApiGatewayProxyResultV2] = {
case (result: ApiGatewayProxyStructuredResultV2, kernel) =>
result.copy(headers = kernel.toHeaders ++ result.headers)
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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] = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@armanbilge armanbilge mentioned this pull request Dec 9, 2021
6 tasks
@armanbilge

Copy link
Copy Markdown
Member Author

Integrated with #60, so it will merge in from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants