32
loading...
This website collects cookies to deliver better user experience
POST-INVOKE
event. We then use Distributed Ruby (DRb) from the extension to signal your application to work jobs off a queue. Both of these are synchronous calls. Once complete the LambdaPunch extensions signals it is done and your function is ready for the next request.Gemfile
and then make sure to bundle install
afterward.gem 'lambda_punch'
ensure
section that lets the extension process know the request is done.LambdaPunch.start_server!
def handler(event:, context:)
# ...
ensure
LambdaPunch.handled!(context)
end
Dockerfile
, after you copy your code, add this RUN
command to install the extension within your container's /opt/extensions
directory.RUN bundle exec rake lambda_punch:install
LambdaPunch
with a non-Rails project, add this to your Rake filespec = Gem::Specification.find_by_name 'lambda_punch'
load "#{spec.gem_dir}/lib/lambda_punch/tasks/install.rake"
LambdaPunch.push
method to add blocks of code to your jobs queue.LambdaPunch.push do
# ...
end
def handler(event:, context:)
Lamby.handler $app, event, context
ensure
LambdaPunch.push { NewRelic::Agent.agent.flush_pipe_data }
LambdaPunch.handled!(context)
end
config.active_job.queue_adapter = :lambda_punch
SHUTDOWN
event. If jobs are in the queue when this happens they will have two seconds max to work them down before being lost.error
, so you will not see any LambdaPunch lines in your logs. However, if you want some low level debugging information on how LambdaPunch is working, you can use this environment variable to change the log level.Environment:
Variables:
LAMBDA_PUNCH_LOG_LEVEL: debug
LambdaPunch.error_handler = lambda { |e| ... }
Duration
metrics will be the sum of your response time combined with your extension's execution time. For example, if your request takes 200ms
to respond but your background task takes 1000ms
your duration will be a combined 1200ms
. For more details see the "Performance impact and extension overhead" section of the Lambda Extensions APIPostRuntimeExtensionsDuration
metric that you can use to isolate your true response times Duration
using some metric math. Here is an example where the metric math above is used in the first "Duration (response)" widget.