Skip to content

Commit

Permalink
add size limit check
Browse files Browse the repository at this point in the history
  • Loading branch information
nhulston committed Oct 8, 2024
1 parent 413b82e commit 0b69656
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions contrib/aws/aws-sdk-go-v2/aws/eventbridge/eventbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
datadogKey = "_datadog"
startTimeKey = "x-datadog-start-time"
resourceNameKey = "x-datadog-resource-name"
maxSizeBytes = 256 * 1024 // 256 KB
)

func init() {
Expand Down Expand Up @@ -106,5 +107,11 @@ func injectTraceContext(ctx context.Context, entryPtr *types.PutEventsRequestEnt
return
}

// Check new detail size
if len(updatedDetail) > maxSizeBytes {
log.Info("Payload size too large to pass context")
return
}

entryPtr.Detail = aws.String(string(updatedDetail))
}
2 changes: 1 addition & 1 deletion contrib/aws/aws-sdk-go-v2/aws/sns/sns.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func injectTraceContext(ctx context.Context, messageAttributes map[string]types.
// https://docs.aws.amazon.com/sns/latest/dg/sns-message-attributes.html
// Only inject if there's room.
if len(messageAttributes) >= maxMessageAttributes {
log.Debug("Cannot inject trace context: message already has maximum allowed attributes")
log.Info("Cannot inject trace context: message already has maximum allowed attributes")
return
}

Expand Down
2 changes: 1 addition & 1 deletion contrib/aws/aws-sdk-go-v2/aws/sqs/sqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func injectTraceContext(ctx context.Context, messageAttributes map[string]types.
// https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-metadata.html#sqs-message-attributes
// Only inject if there's room.
if len(messageAttributes) >= maxMessageAttributes {
log.Debug("Cannot inject trace context: message already has maximum allowed attributes")
log.Info("Cannot inject trace context: message already has maximum allowed attributes")
return
}

Expand Down

0 comments on commit 0b69656

Please sign in to comment.