sentry

package
v0.0.0-...-ce06de6 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package sentry is a heavily modified Go SDK for Sentry dedicated just for Delightful Developer Metrics (DDM), or at least that's the name when I was working on this program.

Index

Constants

View Source
const (
	// HubContextKey is the key used to store the current Hub.
	HubContextKey = contextKey(1)
	// RequestContextKey is the key used to store the current http.Request.
	RequestContextKey = contextKey(2)
)

Keys used to store values in a Context. Use with Context.Value to access values stored by the SDK.

View Source
const SDKVersion = "0.25.0"

The version of the SDK.

Variables

View Source
var Logger = log.New(io.Discard, "[Sentry] ", log.LstdFlags)

Logger is an instance of log.Logger that is use to provide debug information about running Sentry Client can be enabled by either using Logger.SetOutput directly or with Debug client option.

Functions

func AddGlobalEventProcessor

func AddGlobalEventProcessor(processor EventProcessor)

AddGlobalEventProcessor adds processor to the global list of event processors. Global event processors apply to all events.

AddGlobalEventProcessor is deprecated. Most users will prefer to initialize the SDK with Init and provide a ClientOptions.BeforeSend function or use Scope.AddEventProcessor instead.

func ConfigureScope

func ConfigureScope(f func(scope *Scope))

ConfigureScope is a shorthand for CurrentHub().ConfigureScope.

func Flush

func Flush(timeout time.Duration) bool

Flush waits until the underlying Transport sends any buffered events to the Sentry server, blocking for at most the given timeout. It returns false if the timeout was reached. In that case, some events may not have been sent.

Flush should be called before terminating the program to avoid unintentionally dropping events.

Do not call Flush indiscriminately after every call to CaptureEvent, CaptureException or CaptureMessage. Instead, to have the SDK send events over the network synchronously, configure it to use the HTTPSyncTransport in the call to Init.

func HasHubOnContext

func HasHubOnContext(ctx context.Context) bool

HasHubOnContext checks whether Hub instance is bound to a given Context struct.

func Init

func Init(options ClientOptions) error

Init initializes the SDK with options. The returned error is non-nil if options is invalid, for instance if a malformed DSN is provided.

func PopScope

func PopScope()

PopScope is a shorthand for CurrentHub().PopScope.

func PushScope

func PushScope()

PushScope is a shorthand for CurrentHub().PushScope.

func SetHubOnContext

func SetHubOnContext(ctx context.Context, hub *Hub) context.Context

SetHubOnContext stores given Hub instance on the Context struct and returns a new Context.

func WithScope

func WithScope(f func(scope *Scope))

WithScope is a shorthand for CurrentHub().WithScope.

Types

type Attachment

type Attachment struct {
	Filename    string
	ContentType string
	Payload     []byte
}

Attachment allows associating files with your events to aid in investigation. An event may contain one or more attachments.

type Breadcrumb struct {
	Type      string                 `json:"type,omitempty"`
	Category  string                 `json:"category,omitempty"`
	Message   string                 `json:"message,omitempty"`
	Data      map[string]interface{} `json:"data,omitempty"`
	Level     Level                  `json:"level,omitempty"`
	Timestamp time.Time              `json:"timestamp"`
}

Breadcrumb specifies an application event that occurred before a Sentry event. An event may contain one or more breadcrumbs.

func (b *Breadcrumb) MarshalJSON() ([]byte, error)

MarshalJSON converts the Breadcrumb struct to JSON.

type BreadcrumbHint map[string]interface{}

BreadcrumbHint contains information that can be associated with a Breadcrumb.

type Client

type Client struct {

	// Transport is read-only. Replacing the transport of an existing client is
	// not supported, create a new client instead.
	Transport Transport
	// contains filtered or unexported fields
}

Client is the underlying processor that is used by the main API and Hub instances. It must be created with NewClient.

func NewClient

func NewClient(options ClientOptions) (*Client, error)

NewClient creates and returns an instance of Client configured using ClientOptions.

Most users will not create clients directly. Instead, initialize the SDK with Init and use the package-level functions (for simple programs that run on a single goroutine) or hub methods (for concurrent programs, for example web servers).

func (*Client) AddEventProcessor

func (client *Client) AddEventProcessor(processor EventProcessor)

AddEventProcessor adds an event processor to the client. It must not be called from concurrent goroutines. Most users will prefer to use ClientOptions.BeforeSend or Scope.AddEventProcessor instead.

Note that typical programs have only a single client created by Init and the client is shared among multiple hubs, one per goroutine, such that adding an event processor to the client affects all hubs that share the client.

func (*Client) CaptureEvent

func (client *Client) CaptureEvent(event *Event, hint *EventHint, scope EventModifier) *EventID

CaptureEvent captures an event on the currently active client if any.

The event must already be assembled. Typically code would instead use the utility methods like CaptureException. The return value is the event ID. In case Sentry is disabled or event was dropped, the return value will be nil.

func (*Client) CaptureMetric

func (client *Client) CaptureMetric(metric Metric) *EventID

func (*Client) EventFromMetric

func (client *Client) EventFromMetric(metric Metric) *Event

func (*Client) Flush

func (client *Client) Flush(timeout time.Duration) bool

Flush waits until the underlying Transport sends any buffered events to the Sentry server, blocking for at most the given timeout. It returns false if the timeout was reached. In that case, some events may not have been sent.

Flush should be called before terminating the program to avoid unintentionally dropping events.

Do not call Flush indiscriminately after every call to CaptureEvent, CaptureException or CaptureMessage. Instead, to have the SDK send events over the network synchronously, configure it to use the HTTPSyncTransport in the call to Init.

func (*Client) GetSDKIdentifier

func (client *Client) GetSDKIdentifier() string

func (*Client) Options

func (client *Client) Options() ClientOptions

Options return ClientOptions for the current Client.

func (*Client) SetSDKIdentifier

func (client *Client) SetSDKIdentifier(identifier string)

type ClientOptions

type ClientOptions struct {
	// The DSN to use. If the DSN is not set, the client is effectively
	// disabled.
	Dsn string
	// In debug mode, the debug information is printed to stdout to help you
	// understand what sentry is doing.
	Debug bool
	// The sample rate for event submission in the range [0.0, 1.0]. By default,
	// all events are sent. Thus, as a historical special case, the sample rate
	// 0.0 is treated as if it was 1.0. To drop all events, set the DSN to the
	// empty string.
	SampleRate float64
	// BeforeSend is called before error events are sent to Sentry.
	// Use it to mutate the event or return nil to discard the event.
	BeforeSend func(event *Event, hint *EventHint) *Event

	// io.Writer implementation that should be used with the Debug mode.
	DebugWriter io.Writer
	// The transport to use. Defaults to HTTPTransport.
	Transport Transport
	// The server name to be reported.
	ServerName string
	// The release to be sent with events.
	//
	// Some Sentry features are built around releases, and, thus, reporting
	// events with a non-empty release improves the product experience. See
	// https://docs.sentry.io/product/releases/.
	//
	// If Release is not set, the SDK will try to derive a default value
	// from environment variables or the Git repository in the working
	// directory.
	//
	// If you distribute a compiled binary, it is recommended to set the
	// Release value explicitly at build time. As an example, you can use:
	//
	// 	go build -ldflags='-X main.release=VALUE'
	//
	// That will set the value of a predeclared variable 'release' in the
	// 'main' package to 'VALUE'. Then, use that variable when initializing
	// the SDK:
	//
	// 	sentry.Init(ClientOptions{Release: release})
	//
	// See https://golang.org/cmd/go/ and https://golang.org/cmd/link/ for
	// the official documentation of -ldflags and -X, respectively.
	Release string
	// The dist to be sent with events.
	Dist string
	// The environment to be sent with events.
	Environment string
	// An optional pointer to http.Client that will be used with a default
	// HTTPTransport. Using your own client will make HTTPTransport, HTTPProxy,
	// HTTPSProxy and CaCerts options ignored.
	HTTPClient *http.Client
	// An optional pointer to http.Transport that will be used with a default
	// HTTPTransport. Using your own transport will make HTTPProxy, HTTPSProxy
	// and CaCerts options ignored.
	HTTPTransport http.RoundTripper
	// An optional HTTP proxy to use.
	// This will default to the HTTP_PROXY environment variable.
	HTTPProxy string
	// An optional HTTPS proxy to use.
	// This will default to the HTTPS_PROXY environment variable.
	// HTTPS_PROXY takes precedence over HTTP_PROXY for https requests.
	HTTPSProxy string
	// An optional set of SSL certificates to use.
	CaCerts *x509.CertPool
	// Default event tags. These are overridden by tags set on a scope.
	Tags map[string]string
}

ClientOptions that configures a SDK Client.

type Context

type Context = map[string]interface{}

type DebugMeta

type DebugMeta struct {
	SdkInfo *DebugMetaSdkInfo `json:"sdk_info,omitempty"`
	Images  []DebugMetaImage  `json:"images,omitempty"`
}

The DebugMeta interface is not used in Golang apps, but may be populated when proxying Events from other platforms, like iOS, Android, and the Web. (See: https://develop.sentry.dev/sdk/event-payloads/debugmeta/ ).

type DebugMetaImage

type DebugMetaImage struct {
	Type        string `json:"type,omitempty"`         // all
	ImageAddr   string `json:"image_addr,omitempty"`   // macho,elf,pe
	ImageSize   int    `json:"image_size,omitempty"`   // macho,elf,pe
	DebugID     string `json:"debug_id,omitempty"`     // macho,elf,pe,wasm,sourcemap
	DebugFile   string `json:"debug_file,omitempty"`   // macho,elf,pe,wasm
	CodeID      string `json:"code_id,omitempty"`      // macho,elf,pe,wasm
	CodeFile    string `json:"code_file,omitempty"`    // macho,elf,pe,wasm,sourcemap
	ImageVmaddr string `json:"image_vmaddr,omitempty"` // macho,elf,pe
	Arch        string `json:"arch,omitempty"`         // macho,elf,pe
	UUID        string `json:"uuid,omitempty"`         // proguard
}

type DebugMetaSdkInfo

type DebugMetaSdkInfo struct {
	SdkName           string `json:"sdk_name,omitempty"`
	VersionMajor      int    `json:"version_major,omitempty"`
	VersionMinor      int    `json:"version_minor,omitempty"`
	VersionPatchlevel int    `json:"version_patchlevel,omitempty"`
}

type Dsn

type Dsn struct {
	// contains filtered or unexported fields
}

Dsn is used as the remote address source to client transport.

func NewDsn

func NewDsn(rawURL string) (*Dsn, error)

NewDsn creates a Dsn by parsing rawURL. Most users will never call this function directly. It is provided for use in custom Transport implementations.

func (Dsn) GetAPIURL

func (dsn Dsn) GetAPIURL() *url.URL

GetAPIURL returns the URL of the envelope endpoint of the project associated with the DSN.

func (Dsn) GetHost

func (dsn Dsn) GetHost() string

Get the host of the DSN.

func (Dsn) GetPath

func (dsn Dsn) GetPath() string

Get the path of the DSN.

func (Dsn) GetPort

func (dsn Dsn) GetPort() int

Get the port of the DSN.

func (Dsn) GetProjectID

func (dsn Dsn) GetProjectID() string

Get the project ID of the DSN.

func (Dsn) GetPublicKey

func (dsn Dsn) GetPublicKey() string

Get the public key of the DSN.

func (Dsn) GetScheme

func (dsn Dsn) GetScheme() string

Get the scheme of the DSN.

func (Dsn) GetSecretKey

func (dsn Dsn) GetSecretKey() string

Get the secret key of the DSN.

func (Dsn) MarshalJSON

func (dsn Dsn) MarshalJSON() ([]byte, error)

MarshalJSON converts the Dsn struct to JSON.

func (Dsn) RequestHeaders deprecated

func (dsn Dsn) RequestHeaders() map[string]string

RequestHeaders returns all the necessary headers that have to be used in the transport when seinding events to the /store endpoint.

Deprecated: This method shall only be used if you want to implement your own transport that sends events to the /store endpoint. If you're using the transport provided by the SDK, all necessary headers to authenticate against the /envelope endpoint are added automatically.

func (Dsn) String

func (dsn Dsn) String() string

String formats Dsn struct into a valid string url.

func (*Dsn) UnmarshalJSON

func (dsn *Dsn) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON data to the Dsn struct.

type DsnParseError

type DsnParseError struct {
	Message string
}

DsnParseError represents an error that occurs if a Sentry DSN cannot be parsed.

func (DsnParseError) Error

func (e DsnParseError) Error() string

type DynamicSamplingContext

type DynamicSamplingContext struct {
	Entries map[string]string
	Frozen  bool
}

DynamicSamplingContext holds information about the current event that can be used to make dynamic sampling decisions.

func (DynamicSamplingContext) HasEntries

func (d DynamicSamplingContext) HasEntries() bool

func (DynamicSamplingContext) IsFrozen

func (d DynamicSamplingContext) IsFrozen() bool

type Event

type Event struct {
	EventID     EventID                `json:"event_id,omitempty"`
	Timestamp   time.Time              `json:"timestamp"`
	Sdk         SdkInfo                `json:"sdk,omitempty"`
	Contexts    map[string]Context     `json:"contexts,omitempty"`
	Extra       map[string]interface{} `json:"extra,omitempty"`
	Type        string                 `json:"type,omitempty"`
	Fingerprint []string               `json:"fingerprint,omitempty"`
	Level       Level                  `json:"level,omitempty"`
	Message     string                 `json:"message,omitempty"`
	Platform    string                 `json:"platform,omitempty"`
	Release     string                 `json:"release,omitempty"`
	ServerName  string                 `json:"server_name,omitempty"`
	Threads     []Thread               `json:"threads,omitempty"`
	Tags        map[string]string      `json:"tags,omitempty"`
	Logger      string                 `json:"logger,omitempty"`
	Modules     map[string]string      `json:"modules,omitempty"`
	DebugMeta   *DebugMeta             `json:"debug_meta,omitempty"`

	StartTime time.Time `json:"start_timestamp"`
	// contains filtered or unexported fields
}

Event is the fundamental data structure that is sent to Sentry.

func NewEvent

func NewEvent() *Event

NewEvent creates a new Event.

type EventHint

type EventHint struct {
	Data               interface{}
	EventID            string
	OriginalException  error
	RecoveredException interface{}
	Context            context.Context
	Request            *http.Request
	Response           *http.Response
}

EventHint contains information that can be associated with an Event.

type EventID

type EventID string

EventID is a hexadecimal string representing a unique uuid4 for an Event. An EventID must be 32 characters long, lowercase and not have any dashes.

func CaptureEvent

func CaptureEvent(event *Event) *EventID

CaptureEvent captures an event on the currently active client if any.

The event must already be assembled. Typically code would instead use the utility methods like CaptureException. The return value is the event ID. In case Sentry is disabled or event was dropped, the return value will be nil.

func LastEventID

func LastEventID() EventID

LastEventID returns an ID of last captured event.

type EventModifier

type EventModifier interface {
	ApplyToEvent(event *Event, hint *EventHint) *Event
}

EventModifier is the interface that wraps the ApplyToEvent method.

ApplyToEvent changes an event based on external data and/or an event hint.

type EventProcessor

type EventProcessor func(event *Event, hint *EventHint) *Event

EventProcessor is a function that processes an event. Event processors are used to change an event before it is sent to Sentry.

type Exception

type Exception struct {
	Type      string     `json:"type,omitempty"`  // used as the main issue title
	Value     string     `json:"value,omitempty"` // used as the main issue subtitle
	Module    string     `json:"module,omitempty"`
	ThreadID  string     `json:"thread_id,omitempty"`
	Mechanism *Mechanism `json:"mechanism,omitempty"`
}

Exception specifies an error that occurred.

type HTTPSyncTransport

type HTTPSyncTransport struct {

	// HTTP Client request timeout. Defaults to 30 seconds.
	Timeout time.Duration
	// contains filtered or unexported fields
}

HTTPSyncTransport is a blocking implementation of Transport.

Clients using this transport will send requests to Sentry sequentially and block until a response is returned.

The blocking behavior is useful in a limited set of use cases. For example, use it when deploying code to a Function as a Service ("Serverless") platform, where any work happening in a background goroutine is not guaranteed to execute.

For most cases, prefer HTTPTransport.

func NewHTTPSyncTransport

func NewHTTPSyncTransport() *HTTPSyncTransport

NewHTTPSyncTransport returns a new pre-configured instance of HTTPSyncTransport.

func (*HTTPSyncTransport) Configure

func (t *HTTPSyncTransport) Configure(options ClientOptions)

Configure is called by the Client itself, providing it it's own ClientOptions.

func (*HTTPSyncTransport) Flush

func (t *HTTPSyncTransport) Flush(_ time.Duration) bool

Flush is a no-op for HTTPSyncTransport. It always returns true immediately.

func (*HTTPSyncTransport) SendEvent

func (t *HTTPSyncTransport) SendEvent(event *Event)

SendEvent assembles a new packet out of Event and sends it to remote server.

type HTTPTransport

type HTTPTransport struct {

	// Size of the transport buffer. Defaults to 30.
	BufferSize int
	// HTTP Client request timeout. Defaults to 30 seconds.
	Timeout time.Duration
	// contains filtered or unexported fields
}

HTTPTransport is the default, non-blocking, implementation of Transport.

Clients using this transport will enqueue requests in a buffer and return to the caller before any network communication has happened. Requests are sent to Sentry sequentially from a background goroutine.

func NewHTTPTransport

func NewHTTPTransport() *HTTPTransport

NewHTTPTransport returns a new pre-configured instance of HTTPTransport.

func (*HTTPTransport) Configure

func (t *HTTPTransport) Configure(options ClientOptions)

Configure is called by the Client itself, providing it it's own ClientOptions.

func (*HTTPTransport) Flush

func (t *HTTPTransport) Flush(timeout time.Duration) bool

Flush waits until any buffered events are sent to the Sentry server, blocking for at most the given timeout. It returns false if the timeout was reached. In that case, some events may not have been sent.

Flush should be called before terminating the program to avoid unintentionally dropping events.

Do not call Flush indiscriminately after every call to SendEvent. Instead, to have the SDK send events over the network synchronously, configure it to use the HTTPSyncTransport in the call to Init.

func (*HTTPTransport) SendEvent

func (t *HTTPTransport) SendEvent(event *Event)

SendEvent assembles a new packet out of Event and sends it to remote server.

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

Hub is the central object that manages scopes and clients.

This can be used to capture events and manage the scope. The default hub that is available automatically.

In most situations developers do not need to interface the hub. Instead toplevel convenience functions are exposed that will automatically dispatch to global (CurrentHub) hub. In some situations this might not be possible in which case it might become necessary to manually work with the hub. This is for instance the case when working with async code.

func CurrentHub

func CurrentHub() *Hub

CurrentHub returns an instance of previously initialized Hub stored in the global namespace.

func GetHubFromContext

func GetHubFromContext(ctx context.Context) *Hub

GetHubFromContext tries to retrieve Hub instance from the given Context struct or return nil if one is not found.

func NewHub

func NewHub(client *Client, scope *Scope) *Hub

NewHub returns an instance of a Hub with provided Client and Scope bound.

func (*Hub) BindClient

func (hub *Hub) BindClient(client *Client)

BindClient binds a new Client for the current Hub.

func (*Hub) CaptureEvent

func (hub *Hub) CaptureEvent(event *Event) *EventID

CaptureEvent calls the method of a same name on currently bound Client instance passing it a top-level Scope. Returns EventID if successfully, or nil if there's no Scope or Client available.

func (*Hub) CaptureMetric

func (hub *Hub) CaptureMetric(metric Metric) *EventID

func (*Hub) Client

func (hub *Hub) Client() *Client

Client returns top-level Client of the current Hub or nil if no Client is bound.

func (*Hub) Clone

func (hub *Hub) Clone() *Hub

Clone returns a copy of the current Hub with top-most scope and client copied over.

func (*Hub) ConfigureScope

func (hub *Hub) ConfigureScope(f func(scope *Scope))

ConfigureScope runs f in the current scope.

It is useful to set data that applies to all events that share the current scope.

Modifying the scope affects all references to the current scope.

See also WithScope for making isolated temporary changes.

func (*Hub) Flush

func (hub *Hub) Flush(timeout time.Duration) bool

Flush waits until the underlying Transport sends any buffered events to the Sentry server, blocking for at most the given timeout. It returns false if the timeout was reached. In that case, some events may not have been sent.

Flush should be called before terminating the program to avoid unintentionally dropping events.

Do not call Flush indiscriminately after every call to CaptureEvent, CaptureException or CaptureMessage. Instead, to have the SDK send events over the network synchronously, configure it to use the HTTPSyncTransport in the call to Init.

func (*Hub) LastEventID

func (hub *Hub) LastEventID() EventID

LastEventID returns the ID of the last event (error or message) captured through the hub and sent to the underlying transport.

Transactions and events dropped by sampling or event processors do not change the last event ID.

LastEventID is a convenience method to cover use cases in which errors are captured indirectly and the ID is needed. For example, it can be used as part of an HTTP middleware to log the ID of the last error, if any.

For more flexibility, consider instead using the ClientOptions.BeforeSend function or event processors.

func (*Hub) PopScope

func (hub *Hub) PopScope()

PopScope drops the most recent scope.

Calls to PopScope must be coordinated with PushScope. For most cases, using WithScope should be more convenient.

Calls to PopScope that do not match previous calls to PushScope are silently ignored.

func (*Hub) PushScope

func (hub *Hub) PushScope() *Scope

PushScope pushes a new scope for the current Hub and reuses previously bound Client.

func (*Hub) Scope

func (hub *Hub) Scope() *Scope

Scope returns top-level Scope of the current Hub or nil if no Scope is bound.

func (*Hub) WithScope

func (hub *Hub) WithScope(f func(scope *Scope))

WithScope runs f in an isolated temporary scope.

It is useful when extra data should be sent with a single capture call, for instance a different level or tags.

The scope passed to f starts as a clone of the current scope and can be freely modified without affecting the current scope.

It is a shorthand for PushScope followed by PopScope.

type Integration

type Integration interface {
	Name() string
	SetupOnce(client *Client)
}

Integration allows for registering a functions that modify or discard captured events.

type Level

type Level string

Level marks the severity of the event.

const (
	LevelDebug   Level = "debug"
	LevelInfo    Level = "info"
	LevelWarning Level = "warning"
	LevelError   Level = "error"
	LevelFatal   Level = "fatal"
)

Describes the severity of the event.

type Mechanism

type Mechanism struct {
	Type        string                 `json:"type,omitempty"`
	Description string                 `json:"description,omitempty"`
	HelpLink    string                 `json:"help_link,omitempty"`
	Handled     *bool                  `json:"handled,omitempty"`
	Data        map[string]interface{} `json:"data,omitempty"`
}

Mechanism is the mechanism by which an exception was generated and handled.

func (*Mechanism) SetUnhandled

func (m *Mechanism) SetUnhandled()

SetUnhandled indicates that the exception is an unhandled exception, i.e. from a panic.

type Metric

type Metric []byte

Metric provide a.. type alias for []byte. You should provide a serialized statsd format using the statsd package. For multiple metric entries, please respect the new lines (you should provide the new lines).

type SDKMetaData

type SDKMetaData struct {
	// contains filtered or unexported fields
}

SDKMetaData is a struct to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get send to Sentry.

type Scope

type Scope struct {
	// contains filtered or unexported fields
}

Scope holds contextual data for the current scope.

The scope is an object that can cloned efficiently and stores data that is locally relevant to an event. For instance the scope will hold recorded breadcrumbs and similar information.

The scope can be interacted with in two ways. First, the scope is routinely updated with information by functions such as AddBreadcrumb which will modify the current scope. Second, the current scope can be configured through the ConfigureScope function or Hub method of the same name.

The scope is meant to be modified but not inspected directly. When preparing an event for reporting, the current client adds information from the current scope into the event.

func NewScope

func NewScope() *Scope

NewScope creates a new Scope.

func (*Scope) AddAttachment

func (scope *Scope) AddAttachment(attachment *Attachment)

AddAttachment adds new attachment to the current scope.

func (*Scope) AddBreadcrumb

func (scope *Scope) AddBreadcrumb(breadcrumb *Breadcrumb, limit int)

AddBreadcrumb adds new breadcrumb to the current scope and optionally throws the old one if limit is reached.

func (*Scope) AddEventProcessor

func (scope *Scope) AddEventProcessor(processor EventProcessor)

AddEventProcessor adds an event processor to the current scope.

func (*Scope) ApplyToEvent

func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint) *Event

ApplyToEvent takes the data from the current scope and attaches it to the event.

func (*Scope) Clear

func (scope *Scope) Clear()

Clear removes the data from the current scope. Not safe for concurrent use.

func (*Scope) ClearAttachments

func (scope *Scope) ClearAttachments()

ClearAttachments clears all attachments from the current scope.

func (*Scope) ClearBreadcrumbs

func (scope *Scope) ClearBreadcrumbs()

ClearBreadcrumbs clears all breadcrumbs from the current scope.

func (*Scope) Clone

func (scope *Scope) Clone() *Scope

Clone returns a copy of the current scope with all data copied over.

func (*Scope) RemoveContext

func (scope *Scope) RemoveContext(key string)

RemoveContext removes a context from the current scope.

func (*Scope) RemoveExtra

func (scope *Scope) RemoveExtra(key string)

RemoveExtra removes a extra from the current scope.

func (*Scope) RemoveTag

func (scope *Scope) RemoveTag(key string)

RemoveTag removes a tag from the current scope.

func (*Scope) SetContext

func (scope *Scope) SetContext(key string, value Context)

SetContext adds a context to the current scope.

func (*Scope) SetContexts

func (scope *Scope) SetContexts(contexts map[string]Context)

SetContexts assigns multiple contexts to the current scope.

func (*Scope) SetExtra

func (scope *Scope) SetExtra(key string, value interface{})

SetExtra adds an extra to the current scope.

func (*Scope) SetExtras

func (scope *Scope) SetExtras(extra map[string]interface{})

SetExtras assigns multiple extras to the current scope.

func (*Scope) SetFingerprint

func (scope *Scope) SetFingerprint(fingerprint []string)

SetFingerprint sets new fingerprint for the current scope.

func (*Scope) SetLevel

func (scope *Scope) SetLevel(level Level)

SetLevel sets new level for the current scope.

func (*Scope) SetRequest

func (scope *Scope) SetRequest(r *http.Request)

SetRequest sets the request for the current scope.

func (*Scope) SetRequestBody

func (scope *Scope) SetRequestBody(b []byte)

SetRequestBody sets the request body for the current scope.

This method should only be called when the body bytes are already available in memory. Typically, the request body is buffered lazily from the Request.Body from SetRequest.

func (*Scope) SetTag

func (scope *Scope) SetTag(key, value string)

SetTag adds a tag to the current scope.

func (*Scope) SetTags

func (scope *Scope) SetTags(tags map[string]string)

SetTags assigns multiple tags to the current scope.

func (*Scope) SetUser

func (scope *Scope) SetUser(user User)

SetUser sets the user for the current scope.

type SdkInfo

type SdkInfo struct {
	Name         string       `json:"name,omitempty"`
	Version      string       `json:"version,omitempty"`
	Integrations []string     `json:"integrations,omitempty"`
	Packages     []SdkPackage `json:"packages,omitempty"`
}

SdkInfo contains all metadata about about the SDK being used.

type SdkPackage

type SdkPackage struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

SdkPackage describes a package that was installed.

type Thread

type Thread struct {
	ID      string `json:"id,omitempty"`
	Name    string `json:"name,omitempty"`
	Crashed bool   `json:"crashed,omitempty"`
	Current bool   `json:"current,omitempty"`
}

Thread specifies threads that were running at the time of an event.

type Transport

type Transport interface {
	Flush(timeout time.Duration) bool
	Configure(options ClientOptions)
	SendEvent(event *Event)
}

Transport is used by the Client to deliver events to remote server.

type User

type User struct {
	ID        string            `json:"id,omitempty"`
	Email     string            `json:"email,omitempty"`
	IPAddress string            `json:"ip_address,omitempty"`
	Username  string            `json:"username,omitempty"`
	Name      string            `json:"name,omitempty"`
	Segment   string            `json:"segment,omitempty"`
	Data      map[string]string `json:"data,omitempty"`
}

User describes the user associated with an Event. If this is used, at least an ID or an IP address should be provided.

func (User) IsEmpty

func (u User) IsEmpty() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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