Skip to content

Commit e3c3a3e

Browse files
committed
only setting cfn attribute for aws resources
1 parent 1e3ff4f commit e3c3a3e

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/src/aws-metric-attribute-generator.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -453,23 +453,21 @@ export class AwsMetricAttributeGenerator implements MetricAttributeGenerator {
453453
span.attributes[AwsSpanProcessingUtil.GEN_AI_REQUEST_MODEL]
454454
);
455455
}
456+
457+
if (cloudFormationIdentifier === undefined) {
458+
cloudFormationIdentifier = remoteResourceIdentifier;
459+
}
460+
461+
attributes[AWS_ATTRIBUTE_KEYS.AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER] = cloudFormationIdentifier;
462+
456463
} else if (AwsSpanProcessingUtil.isDBSpan(span)) {
457464
remoteResourceType = DB_CONNECTION_RESOURCE_TYPE;
458465
remoteResourceIdentifier = AwsMetricAttributeGenerator.getDbConnection(span);
459466
}
460467

461-
if (cloudFormationIdentifier === undefined) {
462-
cloudFormationIdentifier = remoteResourceIdentifier;
463-
}
464-
465-
if (
466-
remoteResourceType !== undefined &&
467-
remoteResourceIdentifier !== undefined &&
468-
cloudFormationIdentifier !== undefined
469-
) {
468+
if (remoteResourceType !== undefined && remoteResourceIdentifier !== undefined) {
470469
attributes[AWS_ATTRIBUTE_KEYS.AWS_REMOTE_RESOURCE_TYPE] = remoteResourceType;
471470
attributes[AWS_ATTRIBUTE_KEYS.AWS_REMOTE_RESOURCE_IDENTIFIER] = remoteResourceIdentifier;
472-
attributes[AWS_ATTRIBUTE_KEYS.AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER] = cloudFormationIdentifier;
473471
}
474472
}
475473

0 commit comments

Comments
 (0)