Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sd adapter less verbose on server error #16821

Merged
merged 4 commits into from
Sep 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion mixer/adapter/stackdriver/metric/bufferedClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"hash/fnv"
"io"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -166,7 +167,12 @@ func (b *buffered) Send() {
if err != nil {
ets := handleError(err, timeSeries)
b.updateRetryBuffer(ets)
_ = b.l.Errorf("Stackdriver returned: %v\nGiven data: %v", err, timeSeries)
b.l.Errorf("%d time series was sent and Stackdriver returned: %v\n", len(timeSeries), err) // nolint: errcheck
if isOutOfOrderError(err) {
b.l.Debugf("Given data: %v", timeSeries)
} else {
b.l.Errorf("Given data: %v", timeSeries) // nolint: errcheck
}
} else {
b.l.Debugf("Successfully sent data to Stackdriver.")
}
Expand Down Expand Up @@ -239,6 +245,15 @@ func isRetryable(c codes.Code) bool {
return false
}

func isOutOfOrderError(err error) bool {
if s, ok := status.FromError(err); ok {
if strings.Contains(strings.ToLower(s.Message()), "order") {
return true
}
}
return false
}

func toRetryKey(ts *monitoringpb.TimeSeries) (uint64, error) {
hash := fnv.New64()
if len(ts.Points) != 1 {
Expand Down