Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
varunch77 committed Jan 15, 2025
1 parent 4b0a375 commit 459ef7c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/outputs/cloudwatch/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ func resize(dist distribution.Distribution, listMaxSize int) (distList []distrib

func payload(datum *cloudwatch.MetricDatum, entityPresent bool) int {
size := timestampSize
// this multiplier keeps track of how many times we should be adding "EntityMetricData.member.100." to our payload
entityPrefixMultiplier := 1

for _, dimension := range datum.Dimensions {
size += len(*dimension.Name) + len(*dimension.Value) + dimensionOverheads
entityPrefixMultiplier += 2
entityPrefixMultiplier += 2 // Each dimension has Name/Value so we add the entity string twice
}

if datum.MetricName != nil {
Expand All @@ -124,6 +125,7 @@ func payload(datum *cloudwatch.MetricDatum, entityPresent bool) int {
valuesCountsLen := len(datum.Values)
if valuesCountsLen != 0 {
size += valuesCountsLen*valuesCountsOverheads + statisticsSize
// Add the entity string twice for each Value/Count and then 4 more times for the statistic
entityPrefixMultiplier += 2*valuesCountsLen + 4
} else {
size += valueOverheads
Expand Down

0 comments on commit 459ef7c

Please sign in to comment.