Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More ClientOptions.Release documentation #366

Merged
merged 1 commit into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ type ClientOptions struct {
// 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
Expand Down
10 changes: 9 additions & 1 deletion example/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ import (
"github.com/getsentry/sentry-go"
)

// release is the release of this program that will be reported to Sentry.
// Use go build -ldflags='-X main.release=VALUE' to set this value in build
// time.
// If not set, a default release value will be derived in runtime from
// environment variables or the Git repository in the current working directory.
var release string
Comment on lines +25 to +30
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're happy with this suggestion, I'd add the same to other examples, and a similar bit of explanation to https://docs.sentry.io.


func main() {
if len(os.Args) < 2 {
log.Fatalf("usage: %s URL", os.Args[0])
Expand All @@ -32,7 +39,8 @@ func main() {
Dsn: "",
// Enable printing of SDK debug messages.
// Useful when getting started or trying to figure something out.
Debug: true,
Debug: true,
Release: release,
})
if err != nil {
log.Fatalf("sentry.Init: %s", err)
Expand Down
3 changes: 2 additions & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func prettyPrint(data interface{}) {
fmt.Println(string(dbg))
}

// attempts to guess a default release.
// defaultRelease attempts to guess a default release for the currently running
// program.
func defaultRelease() string {
// Search environment variables (EV) known to hold release info.
envs := []string{
Expand Down