Skip to content

Commit 2ea18a9

Browse files
authored
Remove Lambda:Function:Name resource type support (#907)
*Description of changes:* Remove `RemoteResourceTargetIdentifier` attribute which will treat Lambda Function as a regular AWS resource. It may conflict with the current concept that have Lambda function defined as a service. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 77ce771 commit 2ea18a9

File tree

3 files changed

+0
-25
lines changed

3 files changed

+0
-25
lines changed

awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsAttributeKeys.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ private AwsAttributeKeys() {}
6464
static final AttributeKey<String> AWS_SECRET_ARN =
6565
AttributeKey.stringKey("aws.secretsmanager.secret.arn");
6666

67-
static final AttributeKey<String> AWS_LAMBDA_NAME =
68-
AttributeKey.stringKey("aws.lambda.function.name");
69-
7067
static final AttributeKey<String> AWS_LAMBDA_ARN =
7168
AttributeKey.stringKey("aws.lambda.function.arn");
7269

awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGenerator.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_GUARDRAIL_ARN;
4848
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_GUARDRAIL_ID;
4949
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_KNOWLEDGE_BASE_ID;
50-
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LAMBDA_NAME;
5150
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LAMBDA_RESOURCE_ID;
5251
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LOCAL_OPERATION;
5352
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LOCAL_SERVICE;
@@ -493,11 +492,6 @@ private static void setRemoteResourceTypeAndIdentifier(SpanData span, Attributes
493492
Optional.ofNullable(escapeDelimiters(span.getAttributes().get(AWS_SECRET_ARN))));
494493
cloudformationPrimaryIdentifier =
495494
Optional.ofNullable(escapeDelimiters(span.getAttributes().get(AWS_SECRET_ARN)));
496-
} else if (isKeyPresent(span, AWS_LAMBDA_NAME)) {
497-
remoteResourceType = Optional.of(NORMALIZED_LAMBDA_SERVICE_NAME + "::Function");
498-
remoteResourceIdentifier =
499-
getLambdaResourceNameFromAribitraryName(
500-
Optional.ofNullable(escapeDelimiters(span.getAttributes().get(AWS_LAMBDA_NAME))));
501495
} else if (isKeyPresent(span, AWS_LAMBDA_RESOURCE_ID)) {
502496
remoteResourceType = Optional.of(NORMALIZED_LAMBDA_SERVICE_NAME + "::EventSourceMapping");
503497
remoteResourceIdentifier =
@@ -519,16 +513,6 @@ private static void setRemoteResourceTypeAndIdentifier(SpanData span, Attributes
519513
}
520514
}
521515

522-
// NOTE: "name" in this case can be either the lambda name or lambda arn
523-
private static Optional<String> getLambdaResourceNameFromAribitraryName(
524-
Optional<String> arbitraryName) {
525-
if (arbitraryName != null && arbitraryName.get().startsWith("arn:aws:lambda:")) {
526-
Arn resourceArn = Arn.fromString(arbitraryName.get());
527-
return Optional.of(resourceArn.getResource().toString().split(":")[1]);
528-
}
529-
return arbitraryName;
530-
}
531-
532516
private static Optional<String> getSecretsManagerResourceNameFromArn(Optional<String> stringArn) {
533517
Arn resourceArn = Arn.fromString(stringArn.get());
534518
return Optional.of(resourceArn.getResource().toString().split(":")[1]);

awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGeneratorTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_DATA_SOURCE_ID;
2727
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_GUARDRAIL_ID;
2828
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_KNOWLEDGE_BASE_ID;
29-
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LAMBDA_NAME;
3029
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LAMBDA_RESOURCE_ID;
3130
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LOCAL_OPERATION;
3231
import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LOCAL_SERVICE;
@@ -802,11 +801,6 @@ public void testSdkClientSpanWithRemoteResourceAttributes() {
802801
validateRemoteResourceAttributes("AWS::SecretsManager::Secret", "secretName");
803802
mockAttribute(AWS_SECRET_ARN, null);
804803

805-
// Validate behaviour of AWS_LAMBDA_NAME, then remove it.
806-
mockAttribute(AWS_LAMBDA_NAME, "arn:aws:lambda:us-east-1:123456789012:function:functionName");
807-
validateRemoteResourceAttributes("AWS::Lambda::Function", "functionName");
808-
mockAttribute(AWS_LAMBDA_NAME, null);
809-
810804
// Validate behaviour of AWS_LAMBDA_RESOURCE_ID
811805
mockAttribute(AWS_LAMBDA_RESOURCE_ID, "eventSourceId");
812806
validateRemoteResourceAttributes("AWS::Lambda::EventSourceMapping", "eventSourceId");

0 commit comments

Comments
 (0)