Skip to content

Commit

Permalink
DEVPROD-13165 Add more s3.get/s3.put otel attributes (#8543)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackarySantana authored Dec 12, 2024
1 parent 00533ed commit 5d2d5aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions agent/command/s3_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"`
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions agent/command/s3_put.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"`
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 5d2d5aa

Please sign in to comment.