Skip to content

Commit

Permalink
Merge pull request #3716 from weaveworks/dont-save-shortcut-reports
Browse files Browse the repository at this point in the history
performance(aws_collector): don't persist shortcut reports
  • Loading branch information
bboreham committed Oct 21, 2019
2 parents 4a02171 + d516ed9 commit abefd96
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions app/multitenant/aws_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,13 +544,17 @@ func (c *awsCollector) Add(ctx context.Context, rep report.Report, buf []byte) e
return err
}

reportSize, err := c.cfg.S3Store.StoreReportBytes(ctx, reportKey, buf)
if err != nil {
return err
// Shortcut reports are published to nats but not persisted -
// we'll get a full report from the same probe in a few seconds
if !rep.Shortcut {
reportSize, err := c.cfg.S3Store.StoreReportBytes(ctx, reportKey, buf)
if err != nil {
return err
}
reportSizeHistogram.Observe(float64(reportSize))
reportSizePerUser.WithLabelValues(userid).Add(float64(reportSize))
reportsPerUser.WithLabelValues(userid).Inc()
}
reportSizeHistogram.Observe(float64(reportSize))
reportSizePerUser.WithLabelValues(userid).Add(float64(reportSize))
reportsPerUser.WithLabelValues(userid).Inc()

// third, put it in memcache
if c.cfg.MemcacheClient != nil {
Expand All @@ -563,23 +567,25 @@ func (c *awsCollector) Add(ctx context.Context, rep report.Report, buf []byte) e
}
}

// fourth, put the key in dynamodb
dynamoValueSize.WithLabelValues("PutItem").
Add(float64(len(reportKey)))
if !rep.Shortcut {
// fourth, put the key in dynamodb
dynamoValueSize.WithLabelValues("PutItem").
Add(float64(len(reportKey)))

var resp *dynamodb.PutItemOutput
err = instrument.TimeRequestHistogram(ctx, "DynamoDB.PutItem", dynamoRequestDuration, func(_ context.Context) error {
var err error
resp, err = c.putItemInDynamo(rowKey, colKey, reportKey)
return err
})
var resp *dynamodb.PutItemOutput
err = instrument.TimeRequestHistogram(ctx, "DynamoDB.PutItem", dynamoRequestDuration, func(_ context.Context) error {
var err error
resp, err = c.putItemInDynamo(rowKey, colKey, reportKey)
return err
})

if resp.ConsumedCapacity != nil {
dynamoConsumedCapacity.WithLabelValues("PutItem").
Add(float64(*resp.ConsumedCapacity.CapacityUnits))
}
if err != nil {
return err
if resp.ConsumedCapacity != nil {
dynamoConsumedCapacity.WithLabelValues("PutItem").
Add(float64(*resp.ConsumedCapacity.CapacityUnits))
}
if err != nil {
return err
}
}

if rep.Shortcut && c.nats != nil {
Expand Down

0 comments on commit abefd96

Please sign in to comment.