bugsnag-go: github.com/bugsnag/bugsnag-go/sessions Index | Files

package sessions

import "github.com/bugsnag/bugsnag-go/sessions"


Package Files

config.go payload.go publisher.go session.go startup.go tracker.go

func SendStartupSession Uses

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.

type EventCounts Uses

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 Uses

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 Uses

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 Uses

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

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

func NewSessionTracker Uses

func NewSessionTracker(config *SessionTrackingConfiguration) SessionTracker

NewSessionTracker creates a new SessionTracker based on the provided config,

type SessionTrackingConfiguration Uses

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 Uses

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 Uses

func (c *SessionTrackingConfiguration) Update(config *SessionTrackingConfiguration)

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.

Package sessions imports 16 packages (graph) and is imported by 5 packages. Updated 2020-10-29. Refresh now. Tools for package owners.