1313# limitations under the License.
1414
1515"""
16- This file tests that the `otel-instrument ` script included in this repository
16+ This file tests that the `otel-handler ` script included in this repository
1717successfully instruments OTel Python in a mock Lambda environment.
1818"""
1919
@@ -94,7 +94,7 @@ def replace_in_file(filename, old_text, new_text):
9494
9595def mock_aws_lambda_exec_wrapper ():
9696 """Mocks automatically instrumenting user Lambda function by pointing
97- `AWS_LAMBDA_EXEC_WRAPPER` to the `otel-instrument ` script.
97+ `AWS_LAMBDA_EXEC_WRAPPER` to the `otel-handler ` script.
9898
9999 TODO: It would be better if `moto`'s `mock_lambda` supported setting
100100 AWS_LAMBDA_EXEC_WRAPPER so we could make the call to Lambda instead.
@@ -107,7 +107,7 @@ def mock_aws_lambda_exec_wrapper():
107107 # with instrumentation. In this test we just make sure we can complete auto
108108 # instrumentation without error and the correct environment variabels are
109109 # set. A future improvement might have us run `opentelemetry-instrument` in
110- # this process to imitate `otel-instrument `, but our lambda handler does not
110+ # this process to imitate `otel-handler `, but our lambda handler does not
111111 # call other instrumented libraries so we have no use for it for now.
112112
113113 print_environ_program = (
@@ -118,7 +118,7 @@ def mock_aws_lambda_exec_wrapper():
118118
119119 completed_subprocess = subprocess .run (
120120 [
121- os .path .join (INIT_OTEL_SCRIPTS_DIR , "otel-instrument " ),
121+ os .path .join (INIT_OTEL_SCRIPTS_DIR , "otel-handler " ),
122122 "python3" ,
123123 "-c" ,
124124 print_environ_program ,
@@ -128,7 +128,7 @@ def mock_aws_lambda_exec_wrapper():
128128 text = True ,
129129 )
130130
131- # NOTE: Because `otel-instrument ` cannot affect this python environment, we
131+ # NOTE: Because `otel-handler ` cannot affect this python environment, we
132132 # parse the stdout produced by our test python program to update the
133133 # environment in this parent python process.
134134
@@ -171,6 +171,11 @@ class TestAwsLambdaInstrumentor(TestBase):
171171 def setUpClass (cls ):
172172 super ().setUpClass ()
173173 sys .path .append (INIT_OTEL_SCRIPTS_DIR )
174+ replace_in_file (
175+ os .path .join (INIT_OTEL_SCRIPTS_DIR , "otel-handler" ),
176+ 'export LAMBDA_LAYER_PKGS_DIR="/opt/python"' ,
177+ f'export LAMBDA_LAYER_PKGS_DIR="{ TOX_PYTHON_DIRECTORY } "' ,
178+ )
174179 replace_in_file (
175180 os .path .join (INIT_OTEL_SCRIPTS_DIR , "otel-instrument" ),
176181 'export LAMBDA_LAYER_PKGS_DIR="/opt/python"' ,
@@ -198,6 +203,11 @@ def tearDown(self):
198203 def tearDownClass (cls ):
199204 super ().tearDownClass ()
200205 sys .path .remove (INIT_OTEL_SCRIPTS_DIR )
206+ replace_in_file (
207+ os .path .join (INIT_OTEL_SCRIPTS_DIR , "otel-handler" ),
208+ f'export LAMBDA_LAYER_PKGS_DIR="{ TOX_PYTHON_DIRECTORY } "' ,
209+ 'export LAMBDA_LAYER_PKGS_DIR="/opt/python"' ,
210+ )
201211 replace_in_file (
202212 os .path .join (INIT_OTEL_SCRIPTS_DIR , "otel-instrument" ),
203213 f'export LAMBDA_LAYER_PKGS_DIR="{ TOX_PYTHON_DIRECTORY } "' ,
0 commit comments