Categorygithub.com/getsentry/sentry-go
modulepackage
0.31.1
Repository: https://github.com/getsentry/sentry-go.git
Documentation: pkg.go.dev

# README

Sentry

Official Sentry SDK for Go

Build Status Go Report Card Discord go.dev

sentry-go provides a Sentry client implementation for the Go programming language. This is the next generation of the Go SDK for Sentry, intended to replace the raven-go package.

Looking for the old raven-go SDK documentation? See the Legacy client section here. If you want to start using sentry-go instead, check out the migration guide.

Requirements

The only requirement is a Go compiler.

We verify this package against the 3 most recent releases of Go. Those are the supported versions. The exact versions are defined in GitHub workflow.

In addition, we run tests against the current master branch of the Go toolchain, though support for this configuration is best-effort.

Installation

sentry-go can be installed like any other Go library through go get:

$ go get github.com/getsentry/sentry-go@latest

Check out the list of released versions.

Configuration

To use sentry-go, you’ll need to import the sentry-go package and initialize it with your DSN and other options.

If not specified in the SDK initialization, the DSN, Release and Environment are read from the environment variables SENTRY_DSN, SENTRY_RELEASE and SENTRY_ENVIRONMENT, respectively.

More on this in the Configuration section of the official Sentry Go SDK documentation.

Usage

The SDK supports reporting errors and tracking application performance.

To get started, have a look at one of our examples:

We also provide a complete API reference.

For more detailed information about how to get the most out of sentry-go, check out the official documentation:

Resources

License

Licensed under The MIT License, see LICENSE.

Community

Join Sentry's #go channel on Discord to get involved and help us improve the SDK!

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package sentryhttp provides Sentry integration for servers based on the net/http package.
No description provided by the author
Package sentrylogrus provides a simple Logrus hook for Sentry.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AddBreadcrumb records a new breadcrumb.
AddGlobalEventProcessor adds processor to the global list of event processors.
CaptureCheckIn captures a (cron) monitor check-in.
CaptureEvent captures an event on the currently active client if any.
CaptureException captures an error.
CaptureMessage captures an arbitrary message.
ConfigureScope is a shorthand for CurrentHub().ConfigureScope.
ContinueFromHeaders returns a span option that updates the span to continue an existing TraceID and propagates the Dynamic Sampling context.
ContinueFromRequest returns a span option that updates the span to continue an existing trace.
ContinueFromTrace returns a span option that updates the span to continue an existing TraceID.
Continue a trace based on traceparent and bagge values.
CrontabSchedule defines the MonitorSchedule with a cron format.
CurrentHub returns an instance of previously initialized Hub stored in the global namespace.
No description provided by the author
Constructs a new DynamicSamplingContext using a scope and client.
No description provided by the author
ExtractStacktrace creates a new Stacktrace based on the given error.
Flush waits until the underlying Transport sends any buffered events to the Sentry server, blocking for at most the given timeout.
GetHubFromContext tries to retrieve Hub instance from the given Context struct or return nil if one is not found.
HasHubOnContext checks whether Hub instance is bound to a given Context struct.
HTTPtoSpanStatus converts an HTTP status code to a SpanStatus.
Init initializes the SDK with options.
IntervalSchedule defines the MonitorSchedule with an interval format.
LastEventID returns an ID of last captured event.
NewClient creates and returns an instance of Client configured using ClientOptions.
NewDsn creates a Dsn by parsing rawURL.
NewEvent creates a new Event.
NewFrame assembles a stacktrace frame out of runtime.Frame.
NewHTTPSyncTransport returns a new pre-configured instance of HTTPSyncTransport.
NewHTTPTransport returns a new pre-configured instance of HTTPTransport.
NewHub returns an instance of a Hub with provided Client and Scope bound.
No description provided by the author
NewRequest returns a new Sentry Request from the given http.Request.
NewScope creates a new Scope.
NewStacktrace creates a stacktrace using runtime.Callers.
ParseTraceParentContext parses a sentry-trace header and builds a TraceParentContext from the parsed values.
No description provided by the author
PopScope is a shorthand for CurrentHub().PopScope.
No description provided by the author
PushScope is a shorthand for CurrentHub().PushScope.
Recover captures a panic.
RecoverWithContext captures a panic and passes relevant context object.
SetHubOnContext stores given Hub instance on the Context struct and returns a new Context.
SpanFromContext returns the last span stored in the context, or nil if no span is set on the context.
StartSpan starts a new span to describe an operation.
StartTransaction will create a transaction (root span) if there's no existing transaction in the context otherwise, it will return the existing transaction.
TransactionFromContext returns the root span of the current transaction.
WithDescription sets the description of a span.
WithOpName sets the operation name for a given span.
WithScope is a shorthand for CurrentHub().WithScope.
WithSpanOrigin sets the origin of the span.
WithSpanSampled updates the sampling flag for a given span.
WithTransactionName option sets the name of the current transaction.
WithTransactionSource sets the source of the transaction name.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
HubContextKey is the key used to store the current Hub.
Describes the severity of the event.
Describes the severity of the event.
Describes the severity of the event.
Describes the severity of the event.
Describes the severity of the event.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RequestContextKey is the key used to store the current http.Request.
The possible trace sampling decisions are: SampledFalse, SampledUndefined (default) and SampledTrue.
The possible trace sampling decisions are: SampledFalse, SampledUndefined (default) and SampledTrue.
The possible trace sampling decisions are: SampledFalse, SampledUndefined (default) and SampledTrue.
The version of the SDK.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

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.

# Structs

Attachment allows associating files with your events to aid in investigation.
Breadcrumb specifies an application event that occurred before a Sentry event.
No description provided by the author
Client is the underlying processor that is used by the main API and Hub instances.
ClientOptions that configures a SDK Client.
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.
No description provided by the author
No description provided by the author
Dsn is used as the remote address source to client transport.
DsnParseError represents an error that occurs if a Sentry DSN cannot be parsed.
DynamicSamplingContext holds information about the current event that can be used to make dynamic sampling decisions.
Event is the fundamental data structure that is sent to Sentry.
EventHint contains information that can be associated with an Event.
Exception specifies an error that occurred.
Frame represents a function call and it's metadata.
HTTPSyncTransport is a blocking implementation of Transport.
HTTPTransport is the default, non-blocking, implementation of Transport.
Hub is the central object that manages scopes and clients.
Mechanism is the mechanism by which an exception was generated and handled.
No description provided by the author
No description provided by the author
Request contains information on a HTTP request related to the event.
A SamplingContext is passed to a TracesSampler to determine a sampling decision.
Scope holds contextual data for the current scope.
SdkInfo contains all metadata about about the SDK being used.
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.
SdkPackage describes a package that was installed.
A Span is the building block of a Sentry transaction.
Stacktrace holds information about the frames of the stack.
Thread specifies threads that were running at the time of an event.
A TraceContext carries information about an ongoing trace and is meant to be stored in Event.Contexts (as *TraceContext).
TraceParentContext describes the context of a (remote) parent span.
Contains information about how the name of the transaction was determined.
User describes the user associated with an Event.

# Interfaces

EventModifier is the interface that wraps the ApplyToEvent method.
Integration allows for registering a functions that modify or discard captured events.
No description provided by the author
Transport is used by the Client to deliver events to remote server.

# Type aliases

BreadcrumbHint contains information that can be associated with a Breadcrumb.
No description provided by the author
No description provided by the author
EventID is a hexadecimal string representing a unique uuid4 for an Event.
EventProcessor is a function that processes an event.
Level marks the severity of the event.
No description provided by the author
Sampled signifies a sampling decision.
SpanID identifies a span.
A SpanOption is a function that can modify the properties of a span.
SpanOrigin indicates what created a trace or a span.
SpanStatus is the status of a span.
TraceID identifies a trace.
The TracesSample type is an adapter to allow the use of ordinary functions as a TracesSampler.
Contains information about how the name of the transaction was determined.