From 5d2d5aa0b38316a00ffdede8241555b2d4641736 Mon Sep 17 00:00:00 2001 From: Zackary Santana <64446617+ZackarySantana@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:02:59 -0500 Subject: [PATCH] DEVPROD-13165 Add more s3.get/s3.put otel attributes (#8543) --- agent/command/s3_get.go | 7 +++++++ agent/command/s3_put.go | 11 +++++++++++ config.go | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/agent/command/s3_get.go b/agent/command/s3_get.go index c4be93bcc0..8314dfd7f0 100644 --- a/agent/command/s3_get.go +++ b/agent/command/s3_get.go @@ -28,6 +28,7 @@ const ( var ( s3GetBucketAttribute = fmt.Sprintf("%s.bucket", s3GetAttribute) s3GetTemporaryCredentialsAttribute = fmt.Sprintf("%s.temporary_credentials", s3GetAttribute) + s3GetRemoteFileAttribute = fmt.Sprintf("%s.remote_file", s3GetAttribute) ) // s3get is a command to fetch a resource from an S3 bucket and download it to @@ -42,6 +43,9 @@ type s3get struct { // RemoteFile is the file path of the file to get, within its bucket. RemoteFile string `mapstructure:"remote_file" plugin:"expand"` + // remoteFile is the file path without any expansions applied. + remoteFile string + // Region is the S3 region where the bucket is located. It defaults to // "us-east-1". Region string `mapstructure:"region" plugin:"region"` @@ -143,6 +147,8 @@ func (c *s3get) shouldRunForVariant(buildVariantName string) bool { // Apply the expansions from the relevant task config // to all appropriate fields of the s3get. func (c *s3get) expandParams(conf *internal.TaskConfig) error { + c.remoteFile = c.RemoteFile + var err error if err = util.ExpandValues(c, &conf.Expansions); err != nil { return errors.Wrap(err, "applying expansions") @@ -174,6 +180,7 @@ func (c *s3get) Execute(ctx context.Context, trace.SpanFromContext(ctx).SetAttributes( attribute.String(s3GetBucketAttribute, c.Bucket), attribute.Bool(s3GetTemporaryCredentialsAttribute, c.AwsSessionToken != ""), + attribute.String(s3GetRemoteFileAttribute, c.remoteFile), ) // create pail bucket diff --git a/agent/command/s3_put.go b/agent/command/s3_put.go index 9581c26de2..bb4c305410 100644 --- a/agent/command/s3_put.go +++ b/agent/command/s3_put.go @@ -33,6 +33,9 @@ const ( var ( s3PutBucketAttribute = fmt.Sprintf("%s.bucket", s3PutAttribute) s3PutTemporaryCredentialsAttribute = fmt.Sprintf("%s.temporary_credentials", s3PutAttribute) + s3PutVisibilityAttribute = fmt.Sprintf("%s.visibility", s3PutAttribute) + s3PutPermissionsAttribute = fmt.Sprintf("%s.permissions", s3PutAttribute) + s3PutRemotePathAttribute = fmt.Sprintf("%s.remote_path", s3PutAttribute) ) // s3pc is a command to put a resource to an S3 bucket and download it to @@ -59,6 +62,9 @@ type s3put struct { // within an S3 bucket. Is a prefix when multiple files are uploaded via LocalFilesIncludeFilter. RemoteFile string `mapstructure:"remote_file" plugin:"expand"` + // remoteFile is the file path without any expansions applied. + remoteFile string + // PreservePath, when set to true, causes multi part uploads uploaded with LocalFilesIncludeFilter to // preserve the original folder structure instead of putting all the files into the same folder PreservePath string ` mapstructure:"preserve_path" plugin:"expand"` @@ -205,6 +211,8 @@ func (s3pc *s3put) validate() error { // Apply the expansions from the relevant task config // to all appropriate fields of the s3put. func (s3pc *s3put) expandParams(conf *internal.TaskConfig) error { + s3pc.remoteFile = s3pc.RemoteFile + var err error if err = util.ExpandValues(s3pc, &conf.Expansions); err != nil { return errors.Wrap(err, "applying expansions") @@ -299,6 +307,9 @@ func (s3pc *s3put) Execute(ctx context.Context, trace.SpanFromContext(ctx).SetAttributes( attribute.String(s3PutBucketAttribute, s3pc.Bucket), attribute.Bool(s3PutTemporaryCredentialsAttribute, s3pc.AwsSessionToken != ""), + attribute.String(s3PutVisibilityAttribute, s3pc.Visibility), + attribute.String(s3PutPermissionsAttribute, s3pc.Permissions), + attribute.String(s3PutRemotePathAttribute, s3pc.remoteFile), ) // create pail bucket diff --git a/config.go b/config.go index 61a835511b..63e3714314 100644 --- a/config.go +++ b/config.go @@ -37,7 +37,7 @@ var ( // Agent version to control agent rollover. The format is the calendar date // (YYYY-MM-DD). - AgentVersion = "2024-12-03-a" + AgentVersion = "2024-12-10" ) const (