Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions instana/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def get_lambda_handler_or_default():

if handler:
parts = handler.split(".")
handler_function = parts.pop()
handler_module = ".".join(parts)
handler_function = parts.pop().strip()
handler_module = ".".join(parts).strip()
except Exception:
pass

Expand Down
22 changes: 21 additions & 1 deletion tests/platforms/test_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ def test_get_handler(self):
self.assertEqual("tests", handler_module)
self.assertEqual("lambda_handler", handler_function)

def test_get_handler_with_multi_subpackages(self):
os.environ["LAMBDA_HANDLER"] = "tests.one.two.three.lambda_handler"
handler_module, handler_function = get_lambda_handler_or_default()

self.assertEqual("tests.one.two.three", handler_module)
self.assertEqual("lambda_handler", handler_function)

def test_get_handler_with_space_in_it(self):
os.environ["LAMBDA_HANDLER"] = " tests.another_module.lambda_handler"
handler_module, handler_function = get_lambda_handler_or_default()

self.assertEqual("tests.another_module", handler_module)
self.assertEqual("lambda_handler", handler_function)

os.environ["LAMBDA_HANDLER"] = "tests.another_module.lambda_handler "
handler_module, handler_function = get_lambda_handler_or_default()

self.assertEqual("tests.another_module", handler_module)
self.assertEqual("lambda_handler", handler_function)

def test_agent_extra_http_headers(self):
os.environ['INSTANA_EXTRA_HTTP_HEADERS'] = "X-Test-Header;X-Another-Header;X-And-Another-Header"
self.create_agent_and_setup_tracer()
Expand Down Expand Up @@ -590,4 +610,4 @@ def test_agent_default_log_level(self):
def test_agent_custom_log_level(self):
os.environ['INSTANA_LOG_LEVEL'] = "eRror"
self.create_agent_and_setup_tracer()
assert self.agent.options.log_level == logging.ERROR
assert self.agent.options.log_level == logging.ERROR