Skip to content

Commit

Permalink
remove lambda remote service override configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyuan-he committed Feb 10, 2025
1 parent 07aad1f commit 882b207
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,13 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
# This addresses a Lambda topology issue in Application Signals.
# More context in PR: https://github.com/aws-observability/aws-otel-python-instrumentation/pull/319
#
# NOTE: The env vars LAMBDA_APPLICATION_SIGNALS_REMOTE_SERVICE and
# LAMBDA_APPLICATION_SIGNALS_REMOTE_ENVIRONMENT were introduced as part of this fix.
# They are optional and allow users to override the default values if needed.
# NOTE: The env var LAMBDA_APPLICATION_SIGNALS_REMOTE_ENVIRONMENT was introduced as part of this fix.
# It is optional and allows users to override the default value if needed.
if span.attributes.get(_RPC_METHOD) == "Invoke":
attributes[AWS_REMOTE_SERVICE] = os.environ.get(
"LAMBDA_APPLICATION_SIGNALS_REMOTE_SERVICE", span.attributes.get(AWS_LAMBDA_FUNCTION_NAME)
)
lambda_function_name = _escape_delimiters(span.attributes.get(AWS_LAMBDA_FUNCTION_NAME))
if lambda_function_name is not None:
attributes[AWS_REMOTE_SERVICE] = lambda_function_name

attributes[AWS_REMOTE_ENVIRONMENT] = (
f'lambda:{os.environ.get("LAMBDA_APPLICATION_SIGNALS_REMOTE_ENVIRONMENT", "default")}'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1195,26 +1195,6 @@ def test_sdk_client_span_with_remote_resource_attributes(self):
self._mock_attribute([AWS_LAMBDA_FUNCTION_NAME, SpanAttributes.RPC_METHOD], [None, None])
os.environ.pop("LAMBDA_APPLICATION_SIGNALS_REMOTE_ENVIRONMENT", None)

# Test AWS Lambda Invoke scenario with user-configured lambda remote service
os.environ["LAMBDA_APPLICATION_SIGNALS_REMOTE_SERVICE"] = "test_downstream_lambda2"
self.span_mock.kind = SpanKind.CLIENT
self._mock_attribute(
[AWS_LAMBDA_FUNCTION_NAME, SpanAttributes.RPC_METHOD],
["testLambdaFunction", "Invoke"],
keys,
values,
)
dependency_attributes = _GENERATOR.generate_metric_attributes_dict_from_span(self.span_mock, self.resource).get(
DEPENDENCY_METRIC
)
self.assertEqual(dependency_attributes.get(AWS_REMOTE_SERVICE), "test_downstream_lambda2")
self.assertEqual(dependency_attributes.get(AWS_REMOTE_ENVIRONMENT), "lambda:default")
self.assertNotIn(AWS_REMOTE_RESOURCE_TYPE, dependency_attributes)
self.assertNotIn(AWS_REMOTE_RESOURCE_IDENTIFIER, dependency_attributes)
self.assertNotIn(AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER, dependency_attributes)
self._mock_attribute([AWS_LAMBDA_FUNCTION_NAME, SpanAttributes.RPC_METHOD], [None, None])
os.environ.pop("LAMBDA_APPLICATION_SIGNALS_REMOTE_SERVICE", None)

# Test AWS Lambda non-Invoke scenario
self.span_mock.kind = SpanKind.CLIENT
lambda_arn = "arn:aws:lambda:us-east-1:123456789012:function:testLambda"
Expand Down

0 comments on commit 882b207

Please sign in to comment.