@@ -23,6 +23,9 @@ def lambda_handler(event: Any, context: MockLambdaContext):
2323 pass
2424
2525
26+ HANDLER_NAME = f'{ __name__ } .{ lambda_handler .__name__ } '
27+
28+
2629# The below mock is based on the following code:
2730# https://github.com/open-telemetry/opentelemetry-python-contrib/blob/ecf5529f99222e7d945eddcaa83acb8a47c9ba42/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py#L57-L66
2831@dataclass
@@ -39,7 +42,7 @@ def test_instrument_aws_lambda(exporter: TestExporter) -> None:
3942 with logfire .span ('span' ):
4043 current_context = get_context ()
4144
42- with mock .patch .dict ('os.environ' , {_HANDLER : 'tests.otel_integrations.test_aws_lambda.lambda_handler' }):
45+ with mock .patch .dict ('os.environ' , {_HANDLER : HANDLER_NAME , 'AWS_LAMBDA_FUNCTION_NAME' : HANDLER_NAME }):
4346 logfire .instrument_aws_lambda (lambda_handler , event_context_extractor = event_context_extractor )
4447
4548 context = MockLambdaContext (
@@ -66,14 +69,14 @@ def test_instrument_aws_lambda(exporter: TestExporter) -> None:
6669 },
6770 },
6871 {
69- 'name' : 'tests.otel_integrations.test_aws_lambda.lambda_handler' ,
72+ 'name' : HANDLER_NAME ,
7073 'context' : {'trace_id' : 1 , 'span_id' : 3 , 'is_remote' : False },
7174 'parent' : {'trace_id' : 1 , 'span_id' : 1 , 'is_remote' : True },
7275 'start_time' : 3000000000 ,
7376 'end_time' : 4000000000 ,
7477 'attributes' : {
7578 'logfire.span_type' : 'span' ,
76- 'logfire.msg' : 'tests.otel_integrations.test_aws_lambda.lambda_handler' ,
79+ 'logfire.msg' : HANDLER_NAME ,
7780 'cloud.resource_id' : 'arn:aws:lambda:us-east-1:123456:function:myfunction:myalias' ,
7881 'faas.invocation_id' : 'mock_aws_request_id' ,
7982 'cloud.account.id' : '123456' ,
0 commit comments