diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py index 29a5b53bb5..33a3b90391 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py @@ -423,12 +423,13 @@ def _instrument(self, **kwargs): """ lambda_handler = os.environ.get(ORIG_HANDLER, os.environ.get(_HANDLER)) if not lambda_handler: - raise ValueError( + logger.warning( ( "Could not find the ORIG_HANDLER or _HANDLER in the environment variables. ", "This instrumentation is runnning inside an aws lambda?", ) ) + return # pylint: disable=attribute-defined-outside-init ( self._wrapped_module_name, diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py index 66f637ee2b..00940547ea 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py @@ -495,7 +495,7 @@ def test_lambda_handles_handler_exception_with_api_gateway_proxy_event( exc_env_patch.stop() - def test_lambda_handles_raises_exception_when_environment_variables_not_present( + def test_lambda_handles_should_do_nothing_when_environment_variables_not_present( self, ): exc_env_patch = mock.patch.dict( @@ -503,9 +503,7 @@ def test_lambda_handles_raises_exception_when_environment_variables_not_present( {_HANDLER: ""}, ) exc_env_patch.start() - - with self.assertRaises(Exception): - AwsLambdaInstrumentor().instrument() + AwsLambdaInstrumentor().instrument() spans = self.memory_exporter.get_finished_spans() self.assertEqual(len(spans), 0)