Skip to content

Commit

Permalink
[add] more log for send fail
Browse files Browse the repository at this point in the history
[fix] crash if call empty GetReservedAttempts
  • Loading branch information
shabicheng committed Sep 24, 2019
1 parent 7f2b85e commit d3a95d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 5 additions & 3 deletions producer/io_worker.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package producer

import (
"github.com/aliyun/aliyun-log-go-sdk"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"math"
"sync"
"sync/atomic"
"time"

sls "github.com/aliyun/aliyun-log-go-sdk"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
)

type CallBack interface {
Expand Down Expand Up @@ -70,6 +71,7 @@ func (ioWorker *IoWorker) sendToServer(producerBatch *ProducerBatch, ioWorkerWai
}
return
}
level.Info(ioWorker.logger).Log("msg", "sendToServer failed", "error", err)
if slsError, ok := err.(*sls.Error); ok {
if _, ok := ioWorker.noRetryStatusCodeMap[int(slsError.HTTPCode)]; ok {
ioWorker.excuteFailedCallback(producerBatch)
Expand Down
9 changes: 9 additions & 0 deletions producer/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,25 @@ func (result *Result) GetErrorCode() string {
}

func (result *Result) GetErrorMessage() string {
if len(result.attemptList) == 0 {
return ""
}
cursor := len(result.attemptList) - 1
return result.attemptList[cursor].ErrorMessage
}

func (result *Result) GetRequestId() string {
if len(result.attemptList) == 0 {
return ""
}
cursor := len(result.attemptList) - 1
return result.attemptList[cursor].RequestId
}

func (result *Result) GetTimeStampMs() int64 {
if len(result.attemptList) == 0 {
return 0
}
cursor := len(result.attemptList) - 1
return result.attemptList[cursor].TimeStampMs
}
Expand Down

0 comments on commit d3a95d1

Please sign in to comment.