Skip to content

Commit 57a499e

Browse files
committed
remove unneeded segment on logrus
1 parent 7f3550a commit 57a499e

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

docs/platforms/go/guides/logrus/index.mdx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -189,30 +189,6 @@ eventHook := sentrylogrus.NewEventHookFromClient(
189189
When using both hooks, ensure you flush both of them before the application exits and register exit handlers for fatal logs to avoid losing pending events.
190190
</Alert>
191191

192-
## Correlating Logs With Traces
193-
194-
To correlate logs with transactions, you need to pass a `context.Context` that contains transaction information to your logger calls. The `sentryhttp` middleware automatically adds transaction information to the request's context.
195-
Here's an example of how to use `WithContext` in an HTTP handler to ensure logs are associated with the correct trace.
196-
197-
```go
198-
// Assume logger is initialized and Sentry hooks are added as shown above.
199-
// var logger *logrus.Logger
200-
201-
func myAsyncHandler(w http.ResponseWriter, r *http.Request) {
202-
// The sentryhttp middleware adds a Hub with transaction information to the request context.
203-
ctx := r.Context()
204-
// By using WithContext, the log entry will be associated with the transaction from the request.
205-
logger.WithContext(ctx).Info("Log inside handler")
206-
w.WriteHeader(http.StatusOK)
207-
fmt.Fprintln(w, "Handler finished, async task running in background.")
208-
}
209-
210-
// In your main function, or wherever you set up your routes:
211-
// Wrap your handler with sentryhttp to automatically start transactions for requests.
212-
sentryHandler := sentryhttp.New(sentryhttp.Options{})
213-
http.Handle("/async", sentryHandler.Handle(http.HandlerFunc(myAsyncHandler)))
214-
```
215-
216192
<Include name="logs/go-ctx-usage-alert.mdx"/>
217193

218194
## Logs

0 commit comments

Comments
 (0)