diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/S3TransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/S3TransactionHelper.java index f3b52c4640..e2203a665d 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/S3TransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/S3TransactionHelper.java @@ -79,8 +79,8 @@ protected void setTransactionTriggerData(Transaction transaction, S3Event s3Even cloudOrigin.withRegion(s3NotificationRecord.getAwsRegion()); if (null != s3NotificationRecord.getS3()) { - if (null != s3NotificationRecord.getS3().getBucket()) { - S3EventNotification.S3BucketEntity bucket = s3NotificationRecord.getS3().getBucket(); + S3EventNotification.S3BucketEntity bucket = s3NotificationRecord.getS3().getBucket(); + if (null != bucket) { ServiceOrigin serviceOrigin = transaction.getContext().getServiceOrigin(); serviceOrigin.withId(bucket.getArn()); serviceOrigin.withName(bucket.getName()); @@ -88,8 +88,8 @@ protected void setTransactionTriggerData(Transaction transaction, S3Event s3Even transaction.withOtelAttribute("aws.s3.bucket", bucket.getName()); } - if (null != s3NotificationRecord.getS3().getObject()) { - final S3EventNotification.S3ObjectEntity object = s3NotificationRecord.getS3().getObject(); + S3EventNotification.S3ObjectEntity object = s3NotificationRecord.getS3().getObject(); + if (null != object) { transaction.withOtelAttribute("aws.s3.key", object.getKey()); } }