Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def _instrument(self, **kwargs):
(
self._wrapped_module_name,
self._wrapped_function_name,
) = lambda_handler.rsplit(".", 1)
) = lambda_handler.replace("/",".").rsplit(".", 1)

flush_timeout_env = os.environ.get(
OTEL_INSTRUMENTATION_AWS_LAMBDA_FLUSH_TIMEOUT, None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,3 +754,36 @@ def test_lambda_handles_handler_exception_with_api_gateway_proxy_event(
self.assertEqual(event.name, "exception")

exc_env_patch.stop()

def test_handler_slash_notation(self):
test_env_patch = mock.patch.dict(
"os.environ",
{
**os.environ,
_HANDLER: "tests/mocks/subdir/slash_handler.slash_notation_handler",
"AWS_LAMBDA_FUNCTION_NAME": "mylambda",
_X_AMZN_TRACE_ID: MOCK_XRAY_TRACE_CONTEXT_NOT_SAMPLED,
OTEL_PROPAGATORS: "tracecontext",
},
)
test_env_patch.start()
reload(propagate)

AwsLambdaInstrumentor().instrument()

mock_execute_lambda()

spans = self.memory_exporter.get_finished_spans()

assert spans
self.assertEqual(len(spans), 1)
span = spans[0]
self.assertEqual(span.name, "tests/mocks/subdir/slash_handler.slash_notation_handler")
self.assertEqual(span.kind, SpanKind.SERVER)
self.assertSpanHasAttributes(
span,
MOCK_LAMBDA_CONTEXT_ATTRIBUTES,
)

test_env_patch.stop()

Loading