Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apm-lambda-extension/testing/functions/ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'elastic-apm'
17 changes: 17 additions & 0 deletions apm-lambda-extension/testing/functions/ruby/ruby_function_error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load_paths = Dir["vendor/bundle/ruby/2.7.0/bundler/gems/**/lib"]
load_paths += Dir["vendor/bundle/ruby/2.7.0/gems/**/lib"]
load_paths += Dir["vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/*"]
load_paths += Dir["vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby"]

$LOAD_PATH.unshift(*load_paths)

require 'json'
require 'elastic-apm'

ElasticAPM.start(service_name: 'LocalLambdaTesting')

def lambda_handler(event:, context:)
raise Exception
ensure
HTTP.post("http://localhost:8200/intake/v2/events", :params => {:flushed => "true"})
end
43 changes: 43 additions & 0 deletions apm-lambda-extension/testing/templates/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sam-testing


# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 20

Parameters:
LayerArn:
Type: String
Description: Function Layer arn
ApmServerURL:
Type: String
Description: APM server URL
ApmSecretToken:
Type: String
Description: APM server secret token

Resources:
TestFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: ../functions/ruby
Handler: ruby_function_error.lambda_handler
Runtime: ruby2.7
PackageType: Zip
Layers:
- !Ref LayerArn
Events:
Test:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /
Method: get
Environment:
Variables:
ELASTIC_APM_LAMBDA_APM_SERVER: !Ref ApmServerURL
ELASTIC_APM_SECRET_TOKEN: !Ref ApmSecretToken
GEM_PATH: vendor/bundle/ruby/2.7.0