File tree 3 files changed +20
-2
lines changed
3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -77,3 +77,15 @@ func (r *operationNameOverride) Apply(o *options) {
77
77
func WithOperationNameOverride (s string ) Option {
78
78
return & operationNameOverride {OperationNameOverride : s }
79
79
}
80
+
81
+ type captureRequestBodyOption struct {
82
+ CaptureRequestBody bool
83
+ }
84
+
85
+ func (c * captureRequestBodyOption ) Apply (o * options ) {
86
+ o .CaptureRequestBody = c .CaptureRequestBody
87
+ }
88
+
89
+ func WithCaptureRequestBody (b bool ) Option {
90
+ return & captureRequestBodyOption {CaptureRequestBody : b }
91
+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ var defaultOptions = &options{
18
18
ReportOn : ReportAlways ,
19
19
Timeout : 1 * time .Second ,
20
20
OperationNameOverride : "" ,
21
+ CaptureRequestBody : true ,
21
22
}
22
23
23
24
type options struct {
@@ -33,6 +34,9 @@ type options struct {
33
34
ReportOn func (error ) bool
34
35
35
36
OperationNameOverride string
37
+
38
+ // CaptureRequestBody configures whether the request body should be sent to Sentry.
39
+ CaptureRequestBody bool
36
40
}
37
41
38
42
func ReportAlways (error ) bool {
Original file line number Diff line number Diff line change @@ -51,8 +51,10 @@ func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor {
51
51
ctx = span .Context ()
52
52
defer span .Finish ()
53
53
54
- // TODO: Perhaps makes sense to use SetRequestBody instead?
55
- hub .Scope ().SetExtra ("requestBody" , req )
54
+ if o .CaptureRequestBody {
55
+ // TODO: Perhaps makes sense to use SetRequestBody instead?
56
+ hub .Scope ().SetExtra ("requestBody" , req )
57
+ }
56
58
defer recoverWithSentry (hub , ctx , o )
57
59
58
60
resp , err := handler (ctx , req )
You can’t perform that action at this time.
0 commit comments