Skip to content
Official Sentry SDK for Go
Go Shell
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
echo feat: New fasthttp integration (#34) Jul 25, 2019
example feat: New fasthttp integration (#34) Jul 25, 2019
fasthttp feat: New fasthttp integration (#34) Jul 25, 2019
gin feat: New fasthttp integration (#34) Jul 25, 2019
http feat: New fasthttp integration (#34) Jul 25, 2019
iris feat: New fasthttp integration (#34) Jul 25, 2019
martini feat: New fasthttp integration (#34) Jul 25, 2019
negroni feat: New fasthttp integration (#34) Jul 25, 2019
scripts build: Bump version when releasing with Craft (#19) Jun 24, 2019
tests test: Added manual test for concurrent setters Jul 26, 2019
.craft.yml build: Bump version when releasing with Craft (#19) Jun 24, 2019
.gitignore feat: Use EventID instead of string and return it from Capture calls May 14, 2019
.golangci.yml ci: Remove unnecessary linters and ignore echo example Jun 19, 2019
.travis.yml test: Added manual test for concurrent setters Jul 26, 2019
CHANGELOG.md fix: Run Contextify integration on Threads as well Jul 29, 2019
CONTRIBUTION.md docs: Update release changelog message in contribution.md Jul 1, 2019
LICENSE misc: Add README and LICENSE files Mar 8, 2019
MIGRATION.md docs: Add transports section to readme Jun 19, 2019
README.md feat: New fasthttp integration (#34) Jul 25, 2019
client.go feat: Move frames context reading into contextifyFramesIntegration Jul 11, 2019
client_test.go ref: Allow empty DSN instead of returning an error Jul 10, 2019
dsn.go ref: Cleanup exports and write most of the docs May 16, 2019
dsn_test.go ref: Cleanup exports and write most of the docs May 16, 2019
errors_test.go feat: Extract stacktraces from 3rd party libraries Apr 23, 2019
go.mod ref: Remove dependence and document how to provide your own certifica… Jun 4, 2019
go.sum ref: Remove dependence and document how to provide your own certifica… Jun 4, 2019
helpers_test.go ref: Ditch Clienter in favour of whole Client struct Apr 26, 2019
hub.go fix: Add RWMutex locks to internal Hub and Scope changes Jul 26, 2019
hub_test.go fix: Add RWMutex locks to internal Hub and Scope changes Jul 26, 2019
integrations.go fix: Run Contextify integration on Threads as well Jul 29, 2019
integrations_test.go feat: Move frames context reading into contextifyFramesIntegration Jul 11, 2019
interfaces.go fix: Check if request has GetBody method before calling it Jun 10, 2019
mocks_test.go ci: Enable all golang-ci linters Jun 19, 2019
scope.go fix: Add RWMutex locks to internal Hub and Scope changes Jul 26, 2019
scope_test.go ref: Update transaction in Clear method and add more tests around set… Jul 23, 2019
sentry.go release: 0.2.1 Jul 29, 2019
sourcereader.go feat: Move frames context reading into contextifyFramesIntegration Jul 11, 2019
sourcereader_test.go feat: Move frames context reading into contextifyFramesIntegration Jul 11, 2019
stacktrace.go feat: Move frames context reading into contextifyFramesIntegration Jul 11, 2019
stacktrace_test.go feat: Move frames context reading into contextifyFramesIntegration Jul 11, 2019
transport.go feat: Use noopTransport when no DSN provided Jul 10, 2019
transport_test.go feat: HTTPTransport implementation May 8, 2019
util.go ci: Enable all golang-ci linters Jun 19, 2019
util_test.go test: Add utils tests May 30, 2019

README.md


Official Sentry SDK for Go

Build Status Go Report Card

sentry-go provides a Sentry client implementation for the Go programming language. This is the next line 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

We verify this package against N-2 recent versions of Go compiler. As of June 2019, those versions are:

  • 1.10
  • 1.11
  • 1.12

Installation

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

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

Or, if you are already using Go Modules, specify a version number as well:

$ go get github.com/getsentry/sentry-go@v0.1.0

Configuration

To use sentry-go, you’ll need to import the sentry-go package and initialize it with the client options that will include your DSN. If you specify the SENTRY_DSN environment variable, you can omit this value from options and it will be picked up automatically for you. The release and environment can also be specified in the environment variables SENTRY_RELEASE and SENTRY_ENVIRONMENT respectively.

More on this in Configuration section.

Usage

By default, Sentry Go SDK uses asynchronous transport, which in the code example below requires an explicit awaiting for event delivery to be finished using sentry.Flush method. It is necessary, because otherwise the program would not wait for the async HTTP calls to return a response, and exit the process immediately when it reached the end of the main function. It would not be required inside a running goroutine or if you would use HTTPSyncTransport, which you can read about in Transports section.

package main

import (
    "fmt"
    "os"
    "time"

    "github.com/getsentry/sentry-go"
)

func main() {
  err := sentry.Init(sentry.ClientOptions{
    Dsn: "___DSN___",
  })

  if err != nil {
    fmt.Printf("Sentry initialization failed: %v\n", err)
  }
  
  f, err := os.Open("filename.ext")
  if err != nil {
    sentry.CaptureException(err)
    sentry.Flush(time.Second * 5)
  }
}

For more detailed information about how to get the most out of sentry-go there is additional documentation available:

Resources:

License

Licensed under the BSD license, see LICENSE

Community

Want to join our Sentry's community-golang channel, get involved and help us improve the SDK?

Do not hesistate to shoot me up an email at kamil@sentry.io for Slack invite!

You can’t perform that action at this time.