Skip to content

Commit 61dc018

Browse files
authored
add hubProvider guide for zerolog (#12248)
1 parent 277777e commit 61dc018

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@ WithBreadcrumbs bool
109109
FlushTimeout time.Duration
110110
```
111111

112+
- Using `hubProvider` for Scoped Sentry Hubs
113+
114+
The hubProvider allows you to configure the Sentry hook to use a custom Sentry hub. This can be particularly useful when you want to scope logs to specific goroutines or operations, enabling more precise grouping and context in Sentry.
115+
116+
You can set a custom hubProvider function using the SetHubProvider method:
117+
118+
```go
119+
sentryHook.SetHubProvider(func() *sentry.Hub {
120+
// Create or return a specific Sentry hub
121+
return sentry.NewHub(sentry.GetCurrentHub().Client(), sentry.NewScope())
122+
})
123+
```
124+
125+
This ensures that logs from specific contexts or threads use the appropriate Sentry hub and scope.
126+
112127
## Usage
113128

114129
Use Zerolog as you normally would, and it will automatically send logs at or above the specified levels to Sentry.

0 commit comments

Comments
 (0)