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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joshwestbrook
Copy link

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

TODO:

  • Update documentation
  • Regression test the lambda layer

end

OpenTelemetry.tracer_provider.force_flush(timeout: flush_timeout)
OpenTelemetry.meter_provider.force_flush(timeout: flush_timeout)
Copy link
Author

Choose a reason for hiding this comment

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

Probably need to throw some trys in here so we don't blow up if the metrics SDK isn't in use

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.

1 participant