Skip to content

Commit 9ca7610

Browse files
committed
Review feedback
Signed-off-by: Bryan Boreham <[email protected]>
1 parent 494bb52 commit 9ca7610

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pkg/chunk/aws/dynamodb_storage_client.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/aws/aws-sdk-go/aws/session"
2323
"github.com/aws/aws-sdk-go/service/dynamodb"
2424
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
25+
"github.com/pkg/errors"
2526
"github.com/prometheus/client_golang/prometheus"
2627
awscommon "github.com/weaveworks/common/aws"
2728
"github.com/weaveworks/common/instrument"
@@ -337,7 +338,7 @@ func (a dynamoDBStorageClient) query(ctx context.Context, query chunk.IndexQuery
337338
sp.SetTag("tableName", query.TableName)
338339
sp.SetTag("hashValue", query.HashValue)
339340
}
340-
return a.DynamoDB.QueryPagesWithContext(ctx, input, func(output *dynamodb.QueryOutput, _ bool) bool {
341+
return a.DynamoDB.QueryPagesWithContext(innerCtx, input, func(output *dynamodb.QueryOutput, _ bool) bool {
341342
pageCount++
342343
if sp := ot.SpanFromContext(innerCtx); sp != nil {
343344
sp.LogFields(otlog.Int("page", pageCount))
@@ -349,10 +350,10 @@ func (a dynamoDBStorageClient) query(ctx context.Context, query chunk.IndexQuery
349350
}
350351

351352
return callback(&dynamoDBReadResponse{items: output.Items})
352-
}, retryer.withRetrys, withErrorHandler(query.TableName, "DynamoDB.QueryPages"))
353+
}, retryer.withRetries, withErrorHandler(query.TableName, "DynamoDB.QueryPages"))
353354
})
354355
if err != nil {
355-
return fmt.Errorf("QueryPage error: table=%v, err=%v", query.TableName, err)
356+
return errors.Wrapf(err, "QueryPages error: table=%v", query.TableName)
356357
}
357358
return err
358359
}

pkg/chunk/aws/retryer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ func newRetryer(ctx context.Context, cfg util.BackoffConfig) *retryer {
2626
}
2727
}
2828

29-
func (r *retryer) withRetrys(req *request.Request) {
29+
func (r *retryer) withRetries(req *request.Request) {
3030
req.Retryer = r
3131
}
3232

3333
// RetryRules return the retry delay that should be used by the SDK before
3434
// making another request attempt for the failed request.
3535
func (r *retryer) RetryRules(req *request.Request) time.Duration {
36+
duration := r.Backoff.NextDelay()
3637
if sp := ot.SpanFromContext(req.Context()); sp != nil {
3738
sp.LogFields(otlog.Int("retry", r.NumRetries()))
3839
}
39-
return r.Backoff.NextDelay()
40+
return duration
4041
}
4142

4243
// ShouldRetry returns if the failed request is retryable.

0 commit comments

Comments
 (0)