-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add lambda ruby wrapper for layer (#1323)
* feat: add lambda ruby wrapper for layer * double quote on env var * feat: revision * feat: change to dev * feat: ensure version control
- Loading branch information
1 parent
4955e0c
commit 4e2e142
Showing
8 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'opentelemetry-sdk' | ||
gem 'opentelemetry-exporter-otlp' | ||
gem 'opentelemetry-instrumentation-all' | ||
gem 'opentelemetry-sdk', '~> 1.4.1' | ||
gem 'opentelemetry-exporter-otlp', '~> 0.26.3' | ||
gem 'opentelemetry-instrumentation-aws_lambda', '~> 0.1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
|
||
build-OTelLayer: | ||
mkdir -p ruby | ||
mkdir -p $(ARTIFACTS_DIR)/ruby/gems/3.2.0 | ||
bundler install --path ruby | ||
bundle config set --global silence_root_warning 1 | ||
bundle config set --local path 'ruby' | ||
bundle install | ||
cp -r ruby/ruby/3.2.0/* $(ARTIFACTS_DIR)/ruby/gems/3.2.0 | ||
cp otel-handler $(ARTIFACTS_DIR)/otel-handler | ||
cp wrapper.rb $(ARTIFACTS_DIR)/wrapper.rb | ||
rm -rf $(ARTIFACTS_DIR)/ruby/gems/3.2.0/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
#!/bin/sh | ||
|
||
export ORIG_HANDLER="$_HANDLER"; | ||
export _HANDLER="/opt/wrapper.otel_wrapper"; | ||
|
||
if [ -z "${OTEL_SERVICE_NAME}" ]; then | ||
export OTEL_SERVICE_NAME="$AWS_LAMBDA_FUNCTION_NAME"; | ||
fi | ||
|
||
# disable HTTP NET by default - otherwise, lambda runtime gets instrumented yielding noise | ||
if [ -z "${OTEL_RUBY_INSTRUMENTATION_NET_HTTP_ENABLED}" ]; then | ||
export OTEL_RUBY_INSTRUMENTATION_NET_HTTP_ENABLED=false; | ||
fi | ||
|
||
export LAMBDA_RESOURCE_ATTRIBUTES="cloud.region=$AWS_REGION,cloud.provider=aws,faas.name=$AWS_LAMBDA_FUNCTION_NAME,faas.version=$AWS_LAMBDA_FUNCTION_VERSION"; | ||
if [ -z "${OTEL_RESOURCE_ATTRIBUTES}" ]; then | ||
export OTEL_RESOURCE_ATTRIBUTES="$LAMBDA_RESOURCE_ATTRIBUTES"; | ||
else | ||
export OTEL_RESOURCE_ATTRIBUTES="$LAMBDA_RESOURCE_ATTRIBUTES,$OTEL_RESOURCE_ATTRIBUTES"; | ||
fi | ||
|
||
exec "$@" | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'opentelemetry/sdk' | ||
require 'opentelemetry/exporter/otlp' | ||
require 'opentelemetry/instrumentation/aws_lambda' | ||
|
||
OpenTelemetry::SDK.configure do |c| | ||
c.use 'OpenTelemetry::Instrumentation::AwsLambda' | ||
end | ||
|
||
def otel_wrapper(event:, context:) | ||
otel_wrapper = OpenTelemetry::Instrumentation::AwsLambda::Handler.new() | ||
otel_wrapper.call_wrapped(event: event, context: context) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ main() { | |
cd .aws-sam/build/OTelLayer/ | ||
zip -qr ../../../"$layerName".zip ruby/ | ||
cd - | ||
echo "Finished" | ||
} | ||
|
||
main "$@" |