Skip to content

Commit 9869674

Browse files
authored
remove lambda remote service override configuration (#325)
**Issue #, if available:** If user decides to override `RemoteService value`, the Lambda Topology issue solution will not be able to support multiple downstream Lambdas. For example, consider lambdaA calls both lambdaB and lambdaC. If the user overrides `LAMBDA_APPLICATION_SIGNALS_REMOTE_SERVICE`, it will effectively hardcode the `RemoteService` value. As a result, we are left with an either/or situation where only one node will be connected to lambdaA in the topology depending on the hardcoded value. This issue is not present when the user does not override this `RemoteService` value because that attribute will dynamically take on whatever the lambda function name is. My proposal is we remove the `LAMBDA_APPLICATION_SIGNALS_REMOTE_SERVICE` env var. That is, we do not allow customers to override the `RemoteService` attribute value. This should not cause issues for customers to lose this configuration option. If the customer needs to change the downstream lambda service name, they can change the lambda function name itself rather than having to use an env var. **Description of changes:** Removing option to override `RemoteService` attribute value. **Test plan:** Sanity e2e test by building custom lambda layer and ensuring the correct EMF Logs are still generated after change. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 07aad1f commit 9869674

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/_aws_metric_attribute_generator.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,13 +457,11 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
457457
# This addresses a Lambda topology issue in Application Signals.
458458
# More context in PR: https://github.com/aws-observability/aws-otel-python-instrumentation/pull/319
459459
#
460-
# NOTE: The env vars LAMBDA_APPLICATION_SIGNALS_REMOTE_SERVICE and
461-
# LAMBDA_APPLICATION_SIGNALS_REMOTE_ENVIRONMENT were introduced as part of this fix.
462-
# They are optional and allow users to override the default values if needed.
460+
# NOTE: The env var LAMBDA_APPLICATION_SIGNALS_REMOTE_ENVIRONMENT was introduced as part of this fix.
461+
# It is optional and allows users to override the default value if needed.
463462
if span.attributes.get(_RPC_METHOD) == "Invoke":
464-
attributes[AWS_REMOTE_SERVICE] = os.environ.get(
465-
"LAMBDA_APPLICATION_SIGNALS_REMOTE_SERVICE", span.attributes.get(AWS_LAMBDA_FUNCTION_NAME)
466-
)
463+
attributes[AWS_REMOTE_SERVICE] = _escape_delimiters(span.attributes.get(AWS_LAMBDA_FUNCTION_NAME))
464+
467465
attributes[AWS_REMOTE_ENVIRONMENT] = (
468466
f'lambda:{os.environ.get("LAMBDA_APPLICATION_SIGNALS_REMOTE_ENVIRONMENT", "default")}'
469467
)

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_metric_attribute_generator.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,26 +1195,6 @@ def test_sdk_client_span_with_remote_resource_attributes(self):
11951195
self._mock_attribute([AWS_LAMBDA_FUNCTION_NAME, SpanAttributes.RPC_METHOD], [None, None])
11961196
os.environ.pop("LAMBDA_APPLICATION_SIGNALS_REMOTE_ENVIRONMENT", None)
11971197

1198-
# Test AWS Lambda Invoke scenario with user-configured lambda remote service
1199-
os.environ["LAMBDA_APPLICATION_SIGNALS_REMOTE_SERVICE"] = "test_downstream_lambda2"
1200-
self.span_mock.kind = SpanKind.CLIENT
1201-
self._mock_attribute(
1202-
[AWS_LAMBDA_FUNCTION_NAME, SpanAttributes.RPC_METHOD],
1203-
["testLambdaFunction", "Invoke"],
1204-
keys,
1205-
values,
1206-
)
1207-
dependency_attributes = _GENERATOR.generate_metric_attributes_dict_from_span(self.span_mock, self.resource).get(
1208-
DEPENDENCY_METRIC
1209-
)
1210-
self.assertEqual(dependency_attributes.get(AWS_REMOTE_SERVICE), "test_downstream_lambda2")
1211-
self.assertEqual(dependency_attributes.get(AWS_REMOTE_ENVIRONMENT), "lambda:default")
1212-
self.assertNotIn(AWS_REMOTE_RESOURCE_TYPE, dependency_attributes)
1213-
self.assertNotIn(AWS_REMOTE_RESOURCE_IDENTIFIER, dependency_attributes)
1214-
self.assertNotIn(AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER, dependency_attributes)
1215-
self._mock_attribute([AWS_LAMBDA_FUNCTION_NAME, SpanAttributes.RPC_METHOD], [None, None])
1216-
os.environ.pop("LAMBDA_APPLICATION_SIGNALS_REMOTE_SERVICE", None)
1217-
12181198
# Test AWS Lambda non-Invoke scenario
12191199
self.span_mock.kind = SpanKind.CLIENT
12201200
lambda_arn = "arn:aws:lambda:us-east-1:123456789012:function:testLambda"

0 commit comments

Comments
 (0)