Skip to content

Commit 6638938

Browse files
authored
Use the newrelic-lambda module (#7)
1 parent 617db6e commit 6638938

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

python/newrelic_lambda_wrapper.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
os.environ.setdefault("NEW_RELIC_DISTRIBUTED_TRACING_ENABLED", "true")
1010
os.environ.setdefault("NEW_RELIC_SERVERLESS_MODE_ENABLED", "true")
1111

12-
# The agent will load some environment variables on module import so we need to perform
13-
# the import after setting the necessary environment variables.
14-
import newrelic.agent # noqa
12+
# The agent will load some environment variables on module import so we need
13+
# to perform the import after setting the necessary environment variables.
14+
import newrelic.agent
15+
from newrelic_lambda.lambda_handler import lambda_handler
1516

1617
newrelic.agent.initialize()
1718

@@ -82,7 +83,7 @@ def get_handler():
8283
wrapped_handler = get_handler()
8384

8485

85-
@newrelic.agent.lambda_handler()
86+
@lambda_handler()
8687
def handler(event, context):
8788
context.iopipe = IOpipeNoOp()
8889
return wrapped_handler(event, context)

python/publish-layers.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function build-python27 {
3434
echo "Building New Relic layer for python2.7"
3535
rm -rf $BUILD_DIR $PY27_DIST
3636
mkdir -p $DIST_DIR
37-
pip install --no-cache-dir -qU newrelic -t $BUILD_DIR/lib/python2.7/site-packages
37+
pip install --no-cache-dir -qU newrelic-lambda -t $BUILD_DIR/lib/python2.7/site-packages
3838
cp newrelic_lambda_wrapper.py $BUILD_DIR/lib/python2.7/site-packages/newrelic_lambda_wrapper.py
3939
find $BUILD_DIR -name '*.pyc' -exec rm -f {} +
4040
zip -rq $PY27_DIST $BUILD_DIR
@@ -84,7 +84,7 @@ function build-python36 {
8484
echo "Building New Relic layer for python3.6"
8585
rm -rf $BUILD_DIR $PY36_DIST
8686
mkdir -p $DIST_DIR
87-
pip install --no-cache-dir -qU newrelic -t $BUILD_DIR/lib/python3.6/site-packages
87+
pip install --no-cache-dir -qU newrelic-lambda -t $BUILD_DIR/lib/python3.6/site-packages
8888
cp newrelic_lambda_wrapper.py $BUILD_DIR/lib/python3.6/site-packages/newrelic_lambda_wrapper.py
8989
find $BUILD_DIR -name '__pycache__' -exec rm -rf {} +
9090
zip -rq $PY36_DIST $BUILD_DIR
@@ -134,7 +134,7 @@ function build-python37 {
134134
echo "Building New Relic layer for python3.7"
135135
rm -rf $BUILD_DIR $PY37_DIST
136136
mkdir -p $DIST_DIR
137-
pip install --no-cache-dir -qU newrelic -t $BUILD_DIR/lib/python3.7/site-packages
137+
pip install --no-cache-dir -qU newrelic-lambda -t $BUILD_DIR/lib/python3.7/site-packages
138138
cp newrelic_lambda_wrapper.py $BUILD_DIR/lib/python3.7/site-packages/newrelic_lambda_wrapper.py
139139
find $BUILD_DIR -name '__pycache__' -exec rm -rf {} +
140140
zip -rq $PY37_DIST $BUILD_DIR
@@ -184,7 +184,7 @@ function build-python38 {
184184
echo "Building New Relic layer for python3.8"
185185
rm -rf $BUILD_DIR $PY38_DIST
186186
mkdir -p $DIST_DIR
187-
pip install --no-cache-dir -qU newrelic -t $BUILD_DIR/lib/python3.8/site-packages
187+
pip install --no-cache-dir -qU newrelic-lambda -t $BUILD_DIR/lib/python3.8/site-packages
188188
cp newrelic_lambda_wrapper.py $BUILD_DIR/lib/python3.8/site-packages/newrelic_lambda_wrapper.py
189189
find $BUILD_DIR -name '__pycache__' -exec rm -rf {} +
190190
zip -rq $PY38_DIST $BUILD_DIR

0 commit comments

Comments
 (0)