Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove lambda remote service override configuration #325

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,11 @@ 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)
)
attributes[AWS_REMOTE_SERVICE] = _escape_delimiters(span.attributes.get(AWS_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
Loading