Skip to content

Commit

Permalink
Add comments about updating payload calculations with entity data (#1483
Browse files Browse the repository at this point in the history
)
  • Loading branch information
varunch77 authored Jan 28, 2025
1 parent e66cec1 commit 44f7d6f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ run:

output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
formats: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true
Expand Down
13 changes: 13 additions & 0 deletions plugins/outputs/cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ func (c *CloudWatch) pushMetricDatum() {
case metric := <-c.metricChan:
entity, datums := c.BuildMetricDatum(metric)
numberOfPartitions := len(datums)
/* We currently do not account for entity information as a part of the payload size.
This is by design and should be revisited once the SDK protocol changes.
In the meantime there has been a payload limit increase applied in the background to accommodate this decision
Otherwise to include entity size you would do something like this:
c.metricDatumBatch.Size += calculateEntitySize(entity)
In addition to calculating the size of the entity object, you might also need to account for any extra bytes that get
added on an individual metric level when entity data is present (depends on how the sdk protocol changes)—something like:
c.metricDatumBatch.Size += payload(datums[i], entityPresent=true)
File diff that could be useful: https://github.com/aws/amazon-cloudwatch-agent/compare/af960d7...459ef7c
*/
for i := 0; i < numberOfPartitions; i++ {
entityStr := entityToString(entity)
c.metricDatumBatch.Partition[entityStr] = append(c.metricDatumBatch.Partition[entityStr], datums[i])
Expand Down
13 changes: 13 additions & 0 deletions plugins/outputs/cloudwatch/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ const (
valueOverheads = 47
// &MetricData.member.1.Unit=Kilobytes/Second
unitOverheads = 42

/* Entity overheads - these would be used to calculate entity size if we decide to include it as a part of the payload.
The three main components are the KeyAttributes key/value pair, Attributes key/value pair, and StrictEntityValidation
// &StrictEntityValidation=false
strictEntityValidationSize = 29
// &EntityMetricData.member.100.Entity.KeyAttributes.entry.1.key= &EntityMetricData.member.100.Entity.KeyAttributes.entry.1.value=
entityKeyAttributesOverhead = 62 + 64
// &EntityMetricData.member.100.Entity.Attributes.entry.1.key= &EntityMetricData.member.100.Entity.Attributes.entry.1.value=
entityAttributesOverhead = 59 + 61
// EntityMetricData.member.100.
entityMetricDataPrefixOverhead = 28
*/
)

// Set seed once.
Expand Down

0 comments on commit 44f7d6f

Please sign in to comment.