sessions

package
v2.4.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 16 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendStartupSession

func SendStartupSession(config *SessionTrackingConfiguration) context.Context

SendStartupSession is called by Bugsnag on startup, which will send a session to Bugsnag and return a context to represent the session of the main goroutine. This is the session associated with any fatal panics that are caught by panicwrap.

Types

type EventCounts

type EventCounts struct {
	Handled   int `json:"handled"`
	Unhandled int `json:"unhandled"`
}

EventCounts register how many handled/unhandled events have happened for this session

type Session

type Session struct {
	StartedAt   time.Time
	ID          uuid.UUID
	EventCounts *EventCounts
}

Session represents a start time and a unique ID that identifies the session.

func IncrementEventCountAndGetSession

func IncrementEventCountAndGetSession(ctx context.Context, unhandled bool) *Session

IncrementEventCountAndGetSession extracts a Bugsnag session from the given context and increments the event count of unhandled or handled events and returns the session

type SessionTracker

type SessionTracker interface {
	StartSession(context.Context) context.Context
	FlushSessions()
}

SessionTracker exposes a method for starting sessions that are used for gauging your application's health

func NewSessionTracker

func NewSessionTracker(config *SessionTrackingConfiguration) SessionTracker

NewSessionTracker creates a new SessionTracker based on the provided config,

type SessionTrackingConfiguration

type SessionTrackingConfiguration struct {
	// PublishInterval defines how often the sessions are sent off to the session server.
	PublishInterval time.Duration

	// AutoCaptureSessions can be set to false to disable automatic session
	// tracking. If you want control over what is deemed a session, you can
	// switch off automatic session tracking with this configuration, and call
	// bugsnag.StartSession() when appropriate for your application. See the
	// official docs for instructions and examples of associating handled
	// errors with sessions and ensuring error rate accuracy on the Bugsnag
	// dashboard. This will default to true, but is stored as an interface to enable
	// us to detect when this option has not been set.
	AutoCaptureSessions interface{}

	// APIKey defines the API key for the Bugsnag project. Same value as for reporting errors.
	APIKey string
	// Endpoint is the URI of the session server to receive session payloads.
	Endpoint string
	// Version defines the current version of the notifier.
	Version string

	// ReleaseStage defines the release stage, e.g. "production" or "staging",
	// that this session occurred in. The release stage, in combination with
	// the app version make up the release that Bugsnag tracks.
	ReleaseStage string
	// Hostname defines the host of the server this application is running on.
	Hostname string
	// AppType defines the type of the application.
	AppType string
	// AppVersion defines the version of the application.
	AppVersion string
	// Transport defines the http.RoundTripper to be used for managing HTTP requests.
	Transport http.RoundTripper

	// The release stages to notify about sessions in. If you set this then
	// bugsnag-go will only send sessions to Bugsnag if the release stage
	// is listed here.
	NotifyReleaseStages []string

	// Logger is the logger that Bugsnag should log to. Uses the same defaults
	// as go's builtin logging package. This logger gets invoked when any error
	// occurs inside the library itself.
	Logger interface {
		Printf(format string, v ...interface{})
	}
	// contains filtered or unexported fields
}

SessionTrackingConfiguration defines the configuration options relevant for session tracking. These are likely a subset of the global bugsnag.Configuration. Users should not modify this struct directly but rather call `bugsnag.Configure(bugsnag.Configuration)` which will update this configuration in return.

func (*SessionTrackingConfiguration) IsAutoCaptureSessions

func (c *SessionTrackingConfiguration) IsAutoCaptureSessions() bool

IsAutoCaptureSessions identifies whether or not the notifier should automatically capture sessions as requests come in. It's a convenience wrapper that allows automatic session capturing to be enabled by default.

func (*SessionTrackingConfiguration) Update

Update modifies the values inside the receiver to match the non-default properties of the given config. Existing properties will not be cleared when given empty fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL