MSP-8976 Up deps
This commit is contained in:
1 parent
ebc3c1dbc5
commit
0d9921bbce
603 files changed
+47715
-13202
No files matched your search
+52
-36
@@ -20,7 +20,7 @@ const (
|
||||
RequestContextKey = contextKey(2)
|
||||
)
|
||||
|
||||
// currentHub is the initial Hub with no Client bound and an empty Scope.
|
||||
// currentHub is the initial Hub with a no-op Client and an empty Scope.
|
||||
var currentHub = NewHub(nil, NewScope())
|
||||
|
||||
// Hub is the central object that manages scopes and clients.
|
||||
@@ -58,7 +58,7 @@ func (l *layer) Client() *Client {
|
||||
func (l *layer) SetClient(c *Client) {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
l.client = c
|
||||
l.client = normalizeClient(c)
|
||||
}
|
||||
|
||||
type stack []*layer
|
||||
@@ -67,7 +67,7 @@ type stack []*layer
|
||||
func NewHub(client *Client, scope *Scope) *Hub {
|
||||
hub := Hub{
|
||||
stack: &stack{{
|
||||
client: client,
|
||||
client: normalizeClient(client),
|
||||
scope: scope,
|
||||
}},
|
||||
}
|
||||
@@ -218,12 +218,12 @@ func (hub *Hub) CaptureEvent(event *Event) *EventID {
|
||||
// CaptureEventWithHint is like CaptureEvent but additionally accepts an EventHint.
|
||||
func (hub *Hub) CaptureEventWithHint(event *Event, hint *EventHint) *EventID {
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil || scope == nil {
|
||||
if scope == nil {
|
||||
return nil
|
||||
}
|
||||
eventID := client.CaptureEvent(event, hint, scope)
|
||||
|
||||
if event.Type != transactionType && eventID != nil {
|
||||
if event != nil && event.Type != transactionType && eventID != nil {
|
||||
hub.mu.Lock()
|
||||
hub.lastEventID = *eventID
|
||||
hub.mu.Unlock()
|
||||
@@ -236,7 +236,7 @@ func (hub *Hub) CaptureEventWithHint(event *Event, hint *EventHint) *EventID {
|
||||
// Returns EventID if successfully, or nil if there's no Scope or Client available.
|
||||
func (hub *Hub) CaptureMessage(message string) *EventID {
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil || scope == nil {
|
||||
if scope == nil {
|
||||
return nil
|
||||
}
|
||||
eventID := client.CaptureMessage(message, nil, scope)
|
||||
@@ -254,7 +254,7 @@ func (hub *Hub) CaptureMessage(message string) *EventID {
|
||||
// Returns EventID if successfully, or nil if there's no Scope or Client available.
|
||||
func (hub *Hub) CaptureException(exception error) *EventID {
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil || scope == nil {
|
||||
if scope == nil {
|
||||
return nil
|
||||
}
|
||||
eventID := client.CaptureException(exception, &EventHint{OriginalException: exception}, scope)
|
||||
@@ -272,13 +272,46 @@ func (hub *Hub) CaptureException(exception error) *EventID {
|
||||
// Returns CheckInID if the check-in was captured successfully, or nil otherwise.
|
||||
func (hub *Hub) CaptureCheckIn(checkIn *CheckIn, monitorConfig *MonitorConfig) *EventID {
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return client.CaptureCheckIn(checkIn, monitorConfig, scope)
|
||||
}
|
||||
|
||||
// WithMonitor runs fn and reports its outcome as check-ins for the cron
|
||||
// monitor identified by monitorSlug.
|
||||
//
|
||||
// An in_progress check-in carrying monitorConfig is sent before fn runs. When
|
||||
// monitorConfig is not nil, Sentry creates the monitor if it does not exist,
|
||||
// or updates its configuration. After fn returns, an ok check-in is sent if
|
||||
// it returned nil, or an error check-in otherwise, along with the measured
|
||||
// duration. If fn panics, an error check-in is sent and the panic continues.
|
||||
//
|
||||
// The error returned by fn is returned unchanged.
|
||||
func (hub *Hub) WithMonitor(monitorSlug string, monitorConfig *MonitorConfig, fn func() error) error {
|
||||
checkInID := hub.CaptureCheckIn(&CheckIn{
|
||||
MonitorSlug: monitorSlug,
|
||||
Status: CheckInStatusInProgress,
|
||||
}, monitorConfig)
|
||||
start := time.Now()
|
||||
|
||||
status := CheckInStatusError
|
||||
defer func() {
|
||||
checkIn := &CheckIn{
|
||||
MonitorSlug: monitorSlug,
|
||||
Status: status,
|
||||
Duration: time.Since(start),
|
||||
}
|
||||
if checkInID != nil {
|
||||
checkIn.ID = *checkInID
|
||||
}
|
||||
hub.CaptureCheckIn(checkIn, nil)
|
||||
}()
|
||||
|
||||
err := fn()
|
||||
if err == nil {
|
||||
status = CheckInStatusOK
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// AddBreadcrumb records a new breadcrumb.
|
||||
//
|
||||
// The total number of breadcrumbs that can be recorded are limited by the
|
||||
@@ -286,12 +319,6 @@ func (hub *Hub) CaptureCheckIn(checkIn *CheckIn, monitorConfig *MonitorConfig) *
|
||||
func (hub *Hub) AddBreadcrumb(breadcrumb *Breadcrumb, hint *BreadcrumbHint) {
|
||||
client := hub.Client()
|
||||
|
||||
// If there's no client, just store it on the scope straight away
|
||||
if client == nil {
|
||||
hub.Scope().AddBreadcrumb(breadcrumb, defaultMaxBreadcrumbs)
|
||||
return
|
||||
}
|
||||
|
||||
limit := client.options.MaxBreadcrumbs
|
||||
switch {
|
||||
case limit < 0:
|
||||
@@ -321,7 +348,7 @@ func (hub *Hub) Recover(err interface{}) *EventID {
|
||||
err = recover()
|
||||
}
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil || scope == nil {
|
||||
if scope == nil {
|
||||
return nil
|
||||
}
|
||||
return client.Recover(err, &EventHint{RecoveredException: err}, scope)
|
||||
@@ -335,7 +362,7 @@ func (hub *Hub) RecoverWithContext(ctx context.Context, err interface{}) *EventI
|
||||
err = recover()
|
||||
}
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil || scope == nil {
|
||||
if scope == nil {
|
||||
return nil
|
||||
}
|
||||
return client.RecoverWithContext(ctx, err, &EventHint{RecoveredException: err}, scope)
|
||||
@@ -353,19 +380,14 @@ func (hub *Hub) RecoverWithContext(ctx context.Context, err interface{}) *EventI
|
||||
// the network synchronously, configure it to use the HTTPSyncTransport in the
|
||||
// call to Init.
|
||||
func (hub *Hub) Flush(timeout time.Duration) bool {
|
||||
client := hub.Client()
|
||||
|
||||
if client == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return client.Flush(timeout)
|
||||
return hub.Client().Flush(timeout)
|
||||
}
|
||||
|
||||
// FlushWithContext waits until the underlying Transport sends any buffered events
|
||||
// to the Sentry server, blocking for at most the duration specified by the context.
|
||||
// It returns false if the context is canceled before the events are sent. In such a case,
|
||||
// some events may not be delivered.
|
||||
// to the Sentry server, blocking for at most the duration specified by the
|
||||
// context. It returns false if capture is disabled or the context is canceled
|
||||
// before the events are sent. In the latter case, some events may not be
|
||||
// delivered.
|
||||
//
|
||||
// FlushWithContext should be called before terminating the program to ensure no
|
||||
// events are unintentionally dropped.
|
||||
@@ -375,13 +397,7 @@ func (hub *Hub) Flush(timeout time.Duration) bool {
|
||||
// configure the SDK to use HTTPSyncTransport during initialization with Init.
|
||||
|
||||
func (hub *Hub) FlushWithContext(ctx context.Context) bool {
|
||||
client := hub.Client()
|
||||
|
||||
if client == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return client.FlushWithContext(ctx)
|
||||
return hub.Client().FlushWithContext(ctx)
|
||||
}
|
||||
|
||||
// GetTraceparent returns the current Sentry traceparent string, to be used as a HTTP header value
|
||||
|
||||
Reference in new issue
Block a user