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

feat: AWS lambda programatic wrap #1308

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

Conversation

joshwestbrook
Copy link

@joshwestbrook joshwestbrook commented Dec 18, 2024

Our company uses container images for deploying our lambda functions and use herokuish Procfile entries as our entrypoints for the images.

This means it takes a ton of jiggery-pokery to get this working for our situation because:

  1. We can't natively pull in a lambda layer without using the AWS S3 CLI to pull down the layer zip and copy into our base image
  2. The _HANDLER environment variable actually contains our Procfile entry (which calls the lambda RIC under the hood with the handler that's expected by this wrapper)

This PR introduces an alternative way of instrumenting by programmatically wrapping an arbitrary handler method for scenarios where using lambda layers aren't an option (such as ours).

Example:

require 'opentelemetry/instrumentation/aws_lambda'

module Example
  class Handler
    extend OpenTelemetry::Instrumentation::AwsLambda::Wrap

    def self.process(event:, context:)
      pp event
    end
    instrument_handler :process
  end
end

@arielvalentin
Copy link
Collaborator

cc: @jterapin @alextwoods @NathanielRN

Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

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

Thanks, @joshwestbrook! It's great to see the lambda instrumentation getting some use and I like your adjustment to make it more flexible for different scenarios.

Since @xuan-cao-swi initially wrote this, I'd like him to also take a look before we merge.

@joshwestbrook
Copy link
Author

Thanks, @joshwestbrook! It's great to see the lambda instrumentation getting some use and I like your adjustment to make it more flexible for different scenarios.

Since @xuan-cao-swi initially wrote this, I'd like him to also take a look before we merge.

Awesome, thanks for taking a look at this @kaylareopelle!

@xuan-cao-swi
Copy link
Contributor

Thanks @joshwestbrook , I think it looks good. Would you mind add some test case around the instrument_handler function.

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.

4 participants