You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/go/common/logs/logrus.mdx
+2-9Lines changed: 2 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
2
title: Logrus
3
-
description: "Logrus is a structured logger for Go, used to log messages in different formats and levels. This guide demonstrates how to integrate Logrus with Sentry to capture and send both logs and events to Sentry."
3
+
description: "Integrate Logrus with Sentry to capture and send both logs and events."
4
+
sidebar_order: 10
4
5
---
5
6
6
7
For a quick reference, there is a [complete example](https://github.com/getsentry/sentry-go/tree/master/_examples/logrus) at the Go SDK source code repository.
@@ -178,11 +179,3 @@ if client != nil {
178
179
</Alert>
179
180
180
181
<Includename="logs/go-ctx-usage-alert.mdx"/>
181
-
182
-
## Logs
183
-
184
-
For comprehensive logging setup with Logrus, including advanced configuration options and best practices, see the [Go Logs documentation](/platforms/go/logs/). The Logrus integration shown above provides seamless integration with Sentry's structured logging features.
185
-
186
-
## Next Steps
187
-
188
-
- Explore [practical guides](/guides/) on what to monitor, log, track, and investigate after setup
Copy file name to clipboardExpand all lines: docs/platforms/go/common/logs/slog.mdx
+2-9Lines changed: 2 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
2
title: Slog
3
-
description: "Slog is a structured logging library for Go, introduced in Go 1.21. This guide demonstrates how to integrate slog with Sentry to capture and send logs to Sentry."
3
+
description: "Integrate slog with Sentry to capture and send structured logs."
4
+
sidebar_order: 20
4
5
---
5
6
6
7
For a quick reference, there is a [complete example](https://github.com/getsentry/sentry-go/tree/master/_examples/slog) at the Go SDK source code repository.
For comprehensive logging setup with slog, including advanced configuration options and best practices, see the [Go Logs documentation](/platforms/go/logs/). The slog integration shown above provides seamless integration with Sentry's structured logging features.
91
-
92
-
## Next Steps
93
-
94
-
- Explore [practical guides](/guides/) on what to monitor, log, track, and investigate after setup
Copy file name to clipboardExpand all lines: docs/platforms/go/common/logs/zap.mdx
+2-5Lines changed: 2 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
2
title: Zap
3
-
description: "Zap is a blazing-fast, structured logging library for Go. This guide demonstrates how to integrate zap with Sentry to capture and send logs to Sentry."
3
+
description: "Integrate Zap with Sentry to capture and send structured logs."
4
+
sidebar_order: 15
4
5
---
5
6
6
7
For a quick reference, there is a [complete example](https://github.com/getsentry/sentry-go/tree/master/_examples/zap) at the Go SDK source code repository.
For comprehensive logging setup with zap, including advanced configuration options and best practices, see the [Go Logs documentation](/platforms/go/logs/). The zap integration shown above provides seamless integration with Sentry's structured logging features.
Copy file name to clipboardExpand all lines: docs/platforms/go/common/logs/zerolog.mdx
+66-36Lines changed: 66 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,20 @@
1
1
---
2
2
title: Zerolog
3
-
description: "Zerolog is a fast and efficient logging library for Go, designed for structured logging. This guide demonstrates how to integrate Zerolog with Sentry."
3
+
description: "Capture error events from Zerolog and send them to Sentry. Note: Zerolog does not support Structured Logs."
4
+
sidebar_order: 30
4
5
---
5
6
7
+
<Alertlevel="warning">
8
+
9
+
The zerolog integration sends error events to Sentry but does not support Structured Logs due to architectural limitations:
10
+
- The `io.Writer` interface lacks access to `context.Context`, preventing proper per-request hub isolation
11
+
- In concurrent applications, breadcrumbs from different requests may leak into each other's events
12
+
- Related issues: [#1178](https://github.com/getsentry/sentry-go/issues/1178), [#1029](https://github.com/getsentry/sentry-go/issues/1029)
13
+
14
+
For Structured Logs, use our Sentry.Logger or any of the supported integrations instead.
15
+
16
+
</Alert>
17
+
6
18
For a complete example, visit the [Go SDK source code repository](https://github.com/getsentry/sentry-go/tree/master/_examples/zerolog).
7
19
8
20
[Go Dev-style API documentation](https://pkg.go.dev/github.com/getsentry/sentry-go/zerolog) is also available.
@@ -14,8 +26,6 @@ go get github.com/getsentry/sentry-go
14
26
go get github.com/getsentry/sentry-go/zerolog
15
27
```
16
28
17
-
<Break />
18
-
19
29
## Configure
20
30
21
31
### Initialize the Sentry SDK
@@ -29,8 +39,8 @@ The sentryzerolog.Options struct has the following fields:
29
39
30
40
```go
31
41
// Levels specifies the log levels that will trigger event sending to Sentry.
32
-
// Only log messages at these levels will be sent. By default, the levels are
33
-
// Error, Fatal, and Panic.
42
+
// Only log messages at these levels will be sent as error events. By default,
43
+
//the levels are Error, Fatal, and Panic.
34
44
Levels []zerolog.Level
35
45
36
46
// WithBreadcrumbs, when enabled, adds log entries as breadcrumbs in Sentry.
@@ -40,43 +50,63 @@ WithBreadcrumbs bool
40
50
41
51
// FlushTimeout sets the maximum duration allowed for flushing events to Sentry.
42
52
// This is the time limit within which all pending events must be sent to Sentry
43
-
// before the application exits. A typical use is ensuring all logs are sent before
44
-
// application shutdown. The default timeout is usually 3 seconds.
53
+
// before the application exits. The default timeout is usually 3 seconds.
45
54
FlushTimeout time.Duration
46
55
```
47
56
48
-
## Verify
57
+
## What Zerolog Integration Supports
58
+
59
+
The zerolog integration **does** support sending **error events** to Sentry:
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.
175
+
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 error events to specific goroutines or operations, enabling more precise grouping and context in Sentry.
146
176
147
177
You can set a custom hubProvider function using the SetHubProvider method:
This ensures that logs from specific contexts or threads use the appropriate Sentry hub and scope.
186
+
This ensures that error events from specific contexts or threads use the appropriate Sentry hub and scope.
157
187
158
188
159
-
Use Zerolog as you normally would, and it will automatically send logs at or above the specified levels to Sentry.
189
+
Use Zerolog as you normally would, and it will automatically send error events at or above the specified levels to Sentry.
160
190
161
191
Note: Ensure Sentry is flushed before the application exits to avoid losing any pending events.
162
192
163
-
## Next Steps
193
+
## Concurrent Applications
164
194
165
-
- Explore [practical guides](/guides/) on what to monitor, log, track, and investigate after setup
195
+
For concurrent applications (HTTP/gRPC servers), use scoped hubs to link error events to traces. See the `hubProvider` section above and the <PlatformLinkto="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> documentation for best practices on proper hub management.
Copy file name to clipboardExpand all lines: docs/platforms/go/common/tracing/index.mdx
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,9 @@ Learn more about tracing <PlatformLink to="/configuration/options/#tracing-optio
34
34
35
35
## Verify
36
36
37
-
Test out tracing by starting and finishing a transaction, which you _must_ do so transactions can be sent to Sentry. Learn how in our <PlatformLinkto="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> content.
37
+
If you're using an HTTP framework with Sentry middleware (Gin, Echo, Fiber, etc.), transactions are created automatically for every incoming request. See <PlatformLinkto="/tracing/instrumentation/auto-instrumentation/">Automatic Instrumentation</PlatformLink> for details.
38
+
39
+
If you're not using a supported framework, you can manually create transactions. Learn how in our <PlatformLinkto="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> content.
38
40
39
41
While you're testing, set <PlatformIdentifiername="traces-sample-rate" /> to `1.0`, as that ensures that every transaction will be sent to Sentry. Once testing is complete, you may want to set a lower <PlatformIdentifiername="traces-sample-rate" /> value, or switch to using <PlatformIdentifiername="traces-sampler" /> to selectively sample and filter your transactions, based on contextual data.
description: "Learn what gets captured automatically when using Sentry's HTTP framework middleware."
4
+
sidebar_order: 10
5
+
---
6
+
7
+
If you're using one of Sentry's HTTP framework middlewares, transactions are created automatically for all incoming HTTP requests when tracing is enabled. No additional code is needed beyond the middleware setup.
Each middleware is installed and configured as part of the framework setup. See the individual guide pages for installation instructions.
28
+
29
+
## HTTP Client Spans
30
+
31
+
For outbound HTTP requests, use the `sentryhttpclient` package to automatically create spans for client requests. See the <PlatformLinkto="/tracing/instrumentation/custom-instrumentation/requests-module/">HTTP Requests</PlatformLink> documentation for details.
32
+
33
+
## Adding Custom Spans
34
+
35
+
Once the middleware creates a transaction, you can add child spans within your handlers to track specific operations. See <PlatformLinkto="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> for details.
0 commit comments