sentry-go

Official Sentry SDK for Go

Github星跟蹤圖

Official Sentry SDK for Go

Build Status
Go Report Card
Discord
GoDoc
go.dev

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 September 2019, those versions are:

  • 1.11
  • 1.12
  • 1.13

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.3.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

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

主要指標

概覽
名稱與所有者getsentry/sentry-go
主編程語言Go
編程語言Go (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2019-03-08 11:02:24
推送於2025-05-30 15:46:18
最后一次提交2025-05-16 08:07:28
發布數107
最新版本名稱zerolog/v0.33.0 (發布於 )
第一版名稱v0.0.1-beta (發布於 2019-05-23 13:54:46)
用户参与
星數1k
關注者數56
派生數230
提交數818
已啟用問題?
問題數399
打開的問題數42
拉請求數489
打開的拉請求數10
關閉的拉請求數97
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?