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

Add lambda-otel4s module #459

Open
wants to merge 66 commits into
base: main
Choose a base branch
from

Conversation

alexcardell
Copy link

@alexcardell alexcardell commented Feb 23, 2024

Supercedes #456

  • Adds lambda-natchez module
  • Adds lambda-otel4s module
    • Traces lambdas with semantic conventions applied
  • Change examples crosstype to add OtelJava example
  • (WIP) Add scalafix migration to port natchez package imports

Discussion

There might be some extra utilities worth exposing to make dealing with batched events (like SQS events) easier -- most likely the context the user wants is on the Record, not the batched Event, but this is pretty equivalent to the existing Natchez module

This is targeting otel4s 0.10.0

Links

https://opentelemetry.io/docs/specs/semconv/faas/aws-lambda/
https://opentelemetry.io/docs/specs/semconv/faas/faas-spans/

@alexcardell
Copy link
Author

Currently pointed at a local snapshot so CI will definitely fail, as otel4s main has NoPublish for everything involving the SDK

@alexcardell alexcardell marked this pull request as ready for review March 12, 2024 19:21
@alexcardell alexcardell changed the title WIP: Add lambda-otel4s module Add lambda-otel4s module Mar 12, 2024
@alexcardell
Copy link
Author

@iRevive Updated all the attributes and removed semconv-experimental

Would appreciate another look when you have time

@iRevive
Copy link

iRevive commented Apr 20, 2024

@alexcardell the changes look good.

We still need to wait for a release of https://github.com/http4s/http4s-otel4s-middleware, right?

@alexcardell
Copy link
Author

The middleware would be useful for the example, but I don't believe it's necessary otherwise

@alexcardell
Copy link
Author

Fixed the 0.9 issues, good to go

@armanbilge
Copy link
Member

There are also some AWS goodies in the upcoming 0.10.0 otel4s release (for otel4s-sdk):

@iRevive is v0.10.0 coming soon?

import feral.lambda.natchez.KernelSource
import org.typelevel.ci._

protected trait KernelSources {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of putting these in the package object, we can put them in the companion object for KernelSource. Then they will automatically be in implicit scope without an import.

Copy link
Member

Choose a reason for hiding this comment

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

@alexcardell Can you look into this as well? 🙏

Copy link
Author

Choose a reason for hiding this comment

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

Will do

Copy link
Author

Choose a reason for hiding this comment

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

@armanbilge done :)

@iRevive
Copy link

iRevive commented Sep 22, 2024

There are also some AWS goodies in the upcoming 0.10.0 otel4s release (for otel4s-sdk):

@iRevive is v0.10.0 coming soon?

We are two PRs away from 0.10.0:

Both are implemented, some minor changes (docs, etc) may be required.

I think we will have 0.10.0 next week.

@armanbilge
Copy link
Member

I am going hang on for otel4s v0.10.0 to avoid back-to-back breaking releases!

@iRevive
Copy link

iRevive commented Sep 24, 2024

0.10.0 is out. It should be a straightforward update.

@armanbilge
Copy link
Member

so fast!!

@alexcardell
Copy link
Author

Updated

libraryDependencies ++= Seq(
"org.typelevel" %%% "otel4s-core-trace" % otel4sVersion,
"org.typelevel" %%% "otel4s-sdk-trace-testkit" % otel4sVersion % Test,
"org.typelevel" %%% "otel4s-semconv-experimental" % otel4sVersion % Test,
Copy link
Member

@armanbilge armanbilge Sep 27, 2024

Choose a reason for hiding this comment

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

Experimental (incubating) semantic conventions. Breaking changes expected. Library instrumentation SHOULD NOT depend on this.

@iRevive should we be concerned? Gah, it's Test, I'm sorry. It's all fine :)

build.sbt Outdated
Comment on lines 182 to 213
"org.tpolecat" %%% "skunk-core" % "0.6.4"
"org.tpolecat" %%% "skunk-core" % "0.6.3"
Copy link
Member

Choose a reason for hiding this comment

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

Why is this rolled back?

Copy link
Author

@alexcardell alexcardell Sep 29, 2024

Choose a reason for hiding this comment

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

The answer to this question is lost to time

If there was a reason I've forgotten, but it's probably a mistake

Bumped back

object TracedHandler {

def apply[F[_]: Monad: Tracer, Event, Result](
handler: Event => F[Option[Result]]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
handler: Event => F[Option[Result]]
handler: F[Option[Result]]

We don't need to pass the event explicitly, because the user obtains it from the Invocation.

Copy link
Author

Choose a reason for hiding this comment

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

Updated

package feral.lambda
package feral.lambda.natchez
Copy link
Member

Choose a reason for hiding this comment

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

Can we add Scalafix migrations for these renames?

Copy link
Author

Choose a reason for hiding this comment

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

Added

Copy link
Author

Choose a reason for hiding this comment

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

Okay so I've added inputs and outputs but what's the common practice for adding the new v0.3.0 dependency, to run those tests? Do we require a 0.2->0.3 subproject and a 0.3->0.4 subproject?

Copy link
Author

Choose a reason for hiding this comment

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

I see the examples in cats have subprojects per version, I will work on that later

Copy link
Member

Choose a reason for hiding this comment

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

Instead of more subprojects, I wonder if we can just delete / replace the old migrations with the new ones since we are doing a version bump? I would prefer not to maintain them forever esp. if Scalafix/Scalameta may issue deprecations in the future 🤔

These migrations are already configured in Scala Steward with a hard-coded version.

https://github.com/scala-steward-org/scala-steward/blob/0765eec5afc158c2e30f5740b4aa23fc7ae0b7dd/modules/core/src/main/resources/scalafix-migrations.conf#L250-L255

Copy link
Author

Choose a reason for hiding this comment

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

Ah, well I added the second subproject (plus shuffling the old one into a nested directory) before reading that

If it can be deleted, great!

Copy link
Author

Choose a reason for hiding this comment

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

Removed

import java.io.ByteArrayOutputStream
import java.util.concurrent.atomic.AtomicInteger

class TracedHandlerSuite extends CatsEffectSuite {
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid the substantial duplication/splitting of these suite? It looks like you based these on some tests that needed extra machinery because they were testing the platform-specific integration. But I think in your situation it should be possible to test TracedHandler using pure code.

Copy link
Author

Choose a reason for hiding this comment

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

Sure thing, makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants