docs(go): align guides with recent SDK releases - #18990
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
c12b9ca to
ad94e7e
Compare
szokeasaurusrex
left a comment
There was a problem hiding this comment.
Mostly lgtm, have a couple comments and questions though
| `PushScope` returns the new scope, so you can configure a temporary scope directly: | ||
|
|
||
| ```go | ||
| scope := sentry.PushScope() | ||
| defer sentry.PopScope() | ||
| scope.SetTag("request.type", "background") | ||
| ``` | ||
|
|
||
| The most useful operation when working with scopes is the <PlatformIdentifier name="configure-scope" /> function. It can be used to reconfigure the current scope. |
There was a problem hiding this comment.
m: I might be missing something, but it seems odd to combine this all into the same section. If I understand correctly, PushScope is an alternative to using ConfigureScope, so it likely makes sense to put it in a separate (sub-)section
| logger.Errorf("oh no!") | ||
|
|
||
| // Fatal level is sent as an error event to Sentry and terminates the application | ||
| logger.Fatalf("can't continue...") |
There was a problem hiding this comment.
l: Would add comments before each of these lines to stay consistent with other lines here and to make it clear to users what they should expect
| ### EventHook | ||
|
|
||
| You also have two ways to create a new `EventHook`. Either by using `sentrylogrus.NewEventHook()` and passing the `sentry.ClientOptions`, or | ||
| by using `sentrylogrus.NewEventFromClient()` and passing an already created `sentry.Client`. These hook captures log entries and | ||
| send them as events. This is helpful for error tracking and alerting. | ||
|
|
||
| #### NewEventHook | ||
| ```go | ||
| eventHook, err := sentrylogrus.NewEventHook( | ||
| []logrus.Level{logrus.ErrorLevel, logrus.FatalLevel, logrus.PanicLevel}, | ||
| sentry.ClientOptions{ | ||
| Dsn: "___PUBLIC_DSN___", | ||
| Debug: true, | ||
| AttachStacktrace: true, | ||
| }, | ||
| ) | ||
| ``` | ||
| #### NewEventHookFromClient | ||
|
|
||
| Use `NewEventHookFromClient` if you've already initialized the Sentry SDK. | ||
| ```go | ||
| if err := sentry.Init(sentry.ClientOptions{ | ||
| Dsn: "https://examplePublicKey@o0.ingest.sentry.io/0", | ||
| }); err != nil { | ||
| log.Fatalf("Sentry initialization failed: %v", err) | ||
| } | ||
| hub := sentry.CurrentHub() | ||
| client := hub.Client() | ||
| if client != nil { | ||
| eventHook := sentrylogrus.NewEventHookFromClient( | ||
| []logrus.Level{logrus.InfoLevel, logrus.WarnLevel}, | ||
| client, | ||
| ) | ||
| } else { | ||
| log.Fatalf("Sentrylogrus initialization failed: nil client") | ||
| } | ||
| ``` |
There was a problem hiding this comment.
[question] are these no longer supported, or simply discouraged?
There was a problem hiding this comment.
no longer supported
|
|
||
| For a quick reference, see the [Fiber v3 example](https://github.com/getsentry/sentry-go/tree/master/_examples/fiber) in the Go SDK source code repository. | ||
|
|
||
| [Go Dev-style API documentation](https://pkg.go.dev/github.com/getsentry/sentry-go/fiberv3) is also available. |
There was a problem hiding this comment.
[question]: It looks like the Go dev docs page duplicates the content on this page. How will these stay in sync?
I would consider avoiding duplicating the docs if the sync process is manual
szokeasaurusrex
left a comment
There was a problem hiding this comment.
lgtm, left some nits that could still be improved but consider them optional
| logger.Errorf("oh no!") | ||
|
|
||
| // Fatal level is sent as an error event to Sentry and terminates the application | ||
| // Fatal also sends an error level log to Sentry, while also terminating the current process. |
There was a problem hiding this comment.
l: you're missing a newline
| // Fatal also sends an error level log to Sentry, while also terminating the current process. | |
| // Fatal also sends an error level log to Sentry, while also terminating the current process. |
| }) | ||
|
|
||
| // Info level is sent as a log to Sentry | ||
| // Sending an info level log to Sentry. |
There was a problem hiding this comment.
l: adding a hyphen makes it a bit clearer that "info" is referring to the log level
| // Sending an info level log to Sentry. | |
| // Sending an info-level log to Sentry. |
| logger.WithField("user", "test-user").Error("An error occurred") | ||
|
|
||
| // Error level is sent as an error event to Sentry | ||
| // Sending an error level log to Sentry. |
There was a problem hiding this comment.
l:
| // Sending an error level log to Sentry. | |
| // Sending an error-level log to Sentry. |
Summary
Testing
git diff --check