mirror of https://github.com/sirupsen/logrus.git
added delivery timeout
This commit is contained in:
parent
8bbc74e9fb
commit
383ab1fb69
|
@ -1,10 +1,17 @@
|
|||
package logrus_sentry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/getsentry/raven-go"
|
||||
)
|
||||
|
||||
const (
|
||||
timeout = 100 * time.Millisecond
|
||||
)
|
||||
|
||||
var (
|
||||
severityMap = map[logrus.Level]raven.Severity{
|
||||
logrus.DebugLevel: raven.DEBUG,
|
||||
|
@ -71,7 +78,14 @@ func (hook *SentryHook) Fire(entry *logrus.Entry) error {
|
|||
}
|
||||
packet.Extra = map[string]interface{}(d)
|
||||
|
||||
hook.client.Capture(packet, nil)
|
||||
_, errCh := hook.client.Capture(packet, nil)
|
||||
timeoutCh := time.After(timeout)
|
||||
select {
|
||||
case err := <-errCh:
|
||||
return err
|
||||
case <-timeoutCh:
|
||||
return fmt.Errorf("no response from sentry server in %s", timeout)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue