Configuration
The Sentry Go SDK has some configurable options, which can enhance your user experience, as well as helping you streamline your error tracking.
SetDSN
The DSN tells the SDK where to send the events. This option is always required
and the Sentry Go SDKs can pick this up from an environment variable (SENTRY_DSN
).
When set to an empty string, SDK won't send any events to Sentry, and all Capture*
methods
will effectively act as no-ops.
raven.SetDSN("https://examplePublicKey@o0.ingest.sentry.io/0")
SetDefaultLoggerName
The logger name used for the events.
raven.SetDefaultLoggerName("some_logger_name")
SetDebug
Outputs some debug logs for capturing and sending events.
raven.SetDebug(true)
SetEnvironment
Sets the environment. This string is freeform and not set by default. A release can be associated
with more than one environment to separate them in the UI (think staging
vs prod
or similar).
raven.SetEnvironment("staging")
SetRelease
Sets the release. Release names are just strings, but the Sentry SDK may detect some formats, and the format might render differently. For more information have a look at the releases documentation.
raven.SetRelease("my-project-name@1.0.0")
SetSampleRate
Configures the sample rate as a percentage of events to be sent in the range of 0.0
to 1.0
. The
default is 1.0
which means that the SDK sends 100% of the events. If set to 0.1
only 10% of the events
will be sent. The Sentry SDK picks events randomly.
raven.SetSampleRate(0.2)
SetIgnoreErrors
A list of messages to be filtered out before being sent to Sentry. This list will form a RegExp, that will check for a partial match of either error's message or the message directly passed by the user.
raven.SetIgnoreErrors([]string{"ThirdPartyServiceUnavailable", "Other error that we want to ignore"})
SetIncludePaths
A list of string prefixes of module names that belong to the app. This option will be used to determine whether the Sentry SDK should mark the frame as the user's or native/external code.
raven.SetIncludePaths([]string{"/some/path", "other/path"})