Skip to content

Commit

Permalink
Make sd adapter less verbose on server error (#16821)
Browse files Browse the repository at this point in the history
* make sd adapter less verbose

* address comment

* add total number of time series

* lint
  • Loading branch information
bianpengyuan authored and istio-testing committed Sep 4, 2019
1 parent 972b39e commit c021dba
Showing 1 changed file with 16 additions and 1 deletion.
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

0 comments on commit c021dba

Please sign in to comment.