Skip to content

Commit 9bd0144

Browse files
committed
Move newrelic import to after default env vars
1 parent 96a4a04 commit 9bd0144

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

python/newrelic_lambda_wrapper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import os
55
import warnings
66

7-
import newrelic.agent
8-
97
os.environ.setdefault("NEW_RELIC_APP_NAME", os.getenv("AWS_LAMBDA_FUNCTION_NAME", ""))
108
os.environ.setdefault("NEW_RELIC_NO_CONFIG_FILE", "true")
119
os.environ.setdefault("NEW_RELIC_DISTRIBUTED_TRACING_ENABLED", "true")
@@ -14,7 +12,12 @@
1412
os.environ.setdefault("NEW_RELIC_LOG_LEVEL", "info")
1513
os.environ.setdefault("NEW_RELIC_SERVERLESS_MODE_ENABLED", "true")
1614

15+
# The agent will load some environment variables on module import so we need to perform
16+
# the import after setting the necessary environment variables.
17+
import newrelic.agent # noqa
18+
1719
newrelic.agent.initialize()
20+
1821
wrapped_handler = None
1922

2023

0 commit comments

Comments
 (0)