@@ -153,20 +153,24 @@ type optionFunc func(*config)
153
153
154
154
func (fn optionFunc ) apply (c * config ) { fn (c ) }
155
155
156
+ type EventHintCallback func (event * sentry.Event , hint * sentry.EventHint ) * sentry.Event
157
+
156
158
type config struct {
157
- levels []zerolog.Level
158
- sampleRate float64
159
- release string
160
- environment string
161
- serverName string
162
- ignoreErrors []string
163
- debug bool
164
- tracing bool
165
- debugWriter io.Writer
166
- httpProxy string
167
- httpsProxy string
168
- caCerts * x509.CertPool
169
- flushTimeout time.Duration
159
+ levels []zerolog.Level
160
+ sampleRate float64
161
+ release string
162
+ environment string
163
+ serverName string
164
+ ignoreErrors []string
165
+ debug bool
166
+ tracing bool
167
+ debugWriter io.Writer
168
+ httpProxy string
169
+ httpsProxy string
170
+ caCerts * x509.CertPool
171
+ flushTimeout time.Duration
172
+ beforeSend sentry.EventProcessor
173
+ tracesSampleRate float64
170
174
}
171
175
172
176
// WithLevels configures zerolog levels that have to be sent to Sentry.
@@ -227,6 +231,20 @@ func WithTracing() WriterOption {
227
231
})
228
232
}
229
233
234
+ // WithTracingSampleRate sets tracing sample rate.
235
+ func WithTracingSampleRate (tsr float64 ) WriterOption {
236
+ return optionFunc (func (cfg * config ) {
237
+ cfg .tracesSampleRate = tsr
238
+ })
239
+ }
240
+
241
+ // WithBeforeSend sets a callback which is called before event is sent.
242
+ func WithBeforeSend (beforeSend sentry.EventProcessor ) WriterOption {
243
+ return optionFunc (func (cfg * config ) {
244
+ cfg .beforeSend = beforeSend
245
+ })
246
+ }
247
+
230
248
// WithDebugWriter enables sentry client tracing.
231
249
func WithDebugWriter (w io.Writer ) WriterOption {
232
250
return optionFunc (func (cfg * config ) {
@@ -263,18 +281,20 @@ func New(dsn string, opts ...WriterOption) (*Writer, error) {
263
281
}
264
282
265
283
err := sentry .Init (sentry.ClientOptions {
266
- Dsn : dsn ,
267
- SampleRate : cfg .sampleRate ,
268
- Release : cfg .release ,
269
- Environment : cfg .environment ,
270
- ServerName : cfg .serverName ,
271
- IgnoreErrors : cfg .ignoreErrors ,
272
- Debug : cfg .debug ,
273
- EnableTracing : cfg .tracing ,
274
- DebugWriter : cfg .debugWriter ,
275
- HTTPProxy : cfg .httpProxy ,
276
- HTTPSProxy : cfg .httpsProxy ,
277
- CaCerts : cfg .caCerts ,
284
+ Dsn : dsn ,
285
+ SampleRate : cfg .sampleRate ,
286
+ Release : cfg .release ,
287
+ Environment : cfg .environment ,
288
+ ServerName : cfg .serverName ,
289
+ IgnoreErrors : cfg .ignoreErrors ,
290
+ Debug : cfg .debug ,
291
+ EnableTracing : cfg .tracing ,
292
+ DebugWriter : cfg .debugWriter ,
293
+ HTTPProxy : cfg .httpProxy ,
294
+ HTTPSProxy : cfg .httpsProxy ,
295
+ CaCerts : cfg .caCerts ,
296
+ BeforeSend : cfg .beforeSend ,
297
+ TracesSampleRate : cfg .tracesSampleRate ,
278
298
})
279
299
280
300
if err != nil {
0 commit comments