Skip to content

Commit 7f3550a

Browse files
committed
refactor segments for consistency
1 parent 9a2a473 commit 7f3550a

File tree

4 files changed

+36
-34
lines changed

4 files changed

+36
-34
lines changed

docs/platforms/go/common/logs/index.mdx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ With Sentry Structured Logs, you can send text based log information from your a
1111

1212
## Requirements
1313

14-
Logs in Go are supported in Sentry Go SDK version `0.33.0` and above. For using integrations of other log libraries, have a look at each specific page for more details on requirements.
14+
Logs in Go are supported in Sentry Go SDK version `0.33.0` and above. To use integrations with other logging libraries, check their specific documentation pages for detailed requirements.
1515

16-
## Setup
16+
## Configure
1717

1818
To enable logging, you need to initialize the SDK with the `EnableLogs` option set to true.
1919

@@ -25,6 +25,31 @@ sentry.Init(sentry.ClientOptions{
2525
})
2626
```
2727

28+
### Options
29+
30+
#### BeforeSendLog
31+
32+
To filter logs, or update them before they are sent to Sentry, you can use the `BeforeSendLog` client option.
33+
34+
```go
35+
sentry.Init(sentry.ClientOptions{
36+
Dsn: "___PUBLIC_DSN___",
37+
EnableLogs: true,
38+
BeforeSendLog: func(log *sentry.Log) *sentry.Log {
39+
// filter out all trace logs
40+
if log.Level == sentry.LogLevelTrace {
41+
return nil
42+
}
43+
44+
// filter all logs below warning
45+
if log.Severity <= sentry.LogSeverityInfo {
46+
return nil
47+
}
48+
return log
49+
},
50+
})
51+
```
52+
2853
## Usage
2954

3055
Once the feature is enabled on the SDK and the SDK is initialized, you can send logs by using the `sentry.Logger` API or our different integrations.
@@ -106,31 +131,6 @@ logger := log.New(sentryLogger, "", log.LstdFlags)
106131
logger.Println("Implementing log.Logger")
107132
```
108133

109-
## Options
110-
111-
### BeforeSendLog
112-
113-
To filter logs, or update them before they are sent to Sentry, you can use the `BeforeSendLog` client option.
114-
115-
```go
116-
sentry.Init(sentry.ClientOptions{
117-
Dsn: "___PUBLIC_DSN___",
118-
EnableLogs: true,
119-
BeforeSendLog: func(log *sentry.Log) *sentry.Log {
120-
// filter out all trace logs
121-
if log.Level == sentry.LogLevelTrace {
122-
return nil
123-
}
124-
125-
// filter all logs below warning
126-
if log.Severity <= sentry.LogSeverityInfo {
127-
return nil
128-
}
129-
return log
130-
},
131-
})
132-
```
133-
134134
### Debug
135135

136136
If the `Debug` init option is set to true, calls to the `sentry.Logger` will also print to the console with the appropriate log level.

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ Go API documentation for the [`sentrylogrus` package](https://pkg.go.dev/github.
1111

1212
Logrus structured logging is supported in Sentry Go SDK version `0.34.0` and above.
1313

14-
## Setup
14+
## Install
1515

1616
Install the `sentrylogrus` package:
1717
```bash
1818
go get github.com/getsentry/sentry-go/logrus
1919
```
2020

21+
## Configure
22+
2123
To enable logging, you need to initialize the SDK with the `EnableLogs` option set to true.
2224

2325
```go
@@ -28,7 +30,7 @@ sentry.Init(sentry.ClientOptions{
2830
})
2931
```
3032

31-
## Configure
33+
### Options
3234

3335
`sentrylogrus` provides two types of hooks to configure the integration with Sentry. Both hooks accept these options:
3436
- **Levels**: A slice of `logrus.Level` specifying which log levels to capture
@@ -117,7 +119,7 @@ func main() {
117119

118120
### LogHook
119121

120-
You have two ways to create a new `LogHook`. Either by using `sentrylogrus.NewLogHook()` and passing the `sentry.ClientOptions` or
122+
You have two ways to create a new `LogHook`. Either by using `sentrylogrus.NewLogHook()` and passing the `sentry.ClientOptions`, or
121123
by using `sentrylogrus.NewLogHookFromClient()` and passing an already created `sentry.Client`. These hook captures log entries and
122124
send them to Sentry's structured logging system.
123125

@@ -151,7 +153,7 @@ logHook := sentrylogrus.NewLogHookFromClient(
151153

152154
### EventHook
153155

154-
You also have two ways to create a new `EventHook`. Either by using `sentrylogrus.NewEventHook()` and passing the `sentry.ClientOptions` or
156+
You also have two ways to create a new `EventHook`. Either by using `sentrylogrus.NewEventHook()` and passing the `sentry.ClientOptions`, or
155157
by using `sentrylogrus.NewEventFromClient()` and passing an already created `sentry.Client`. These hook captures log entries and
156158
send them as events. This is helpful for error tracking and alerting.
157159

@@ -187,7 +189,7 @@ eventHook := sentrylogrus.NewEventHookFromClient(
187189
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.
188190
</Alert>
189191

190-
## Correlating Logs with Traces
192+
## Correlating Logs With Traces
191193

192194
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.
193195
Here's an example of how to use `WithContext` in an HTTP handler to ensure logs are associated with the correct trace.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type Option struct {
7070

7171
## Usage
7272

73-
To integrate Sentry with slog, you need to set up a Sentry handler and configure the Sentry client.
73+
To integrate Sentry with slog, you need to set up a Sentry handler and configure the Sentry client:
7474

7575
```go
7676
func main() {

includes/logs/go-ctx-usage-alert.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Correlating Logs with Traces
1+
## Correlating Logs With Traces
22

33
In order to properly attach the correct trace with each log entry, a `context.Context` is required.
44
If you're using logs combined with tracing, you should pass the correct context to properly attach each trace with the appropriate logs.

0 commit comments

Comments
 (0)