File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -49,3 +49,10 @@ func WithoutMetrics() Option {
49
49
p .excludeMetrics = true
50
50
}
51
51
}
52
+
53
+ // WithRecordStackTrace includes a stack trace inside exception events
54
+ func WithRecordStackTrace () Option {
55
+ return func (p * otelPlugin ) {
56
+ p .recordStackTraceInSpan = true
57
+ }
58
+ }
Original file line number Diff line number Diff line change @@ -28,12 +28,13 @@ var (
28
28
)
29
29
30
30
type otelPlugin struct {
31
- provider trace.TracerProvider
32
- tracer trace.Tracer
33
- attrs []attribute.KeyValue
34
- excludeQueryVars bool
35
- excludeMetrics bool
36
- queryFormatter func (query string ) string
31
+ provider trace.TracerProvider
32
+ tracer trace.Tracer
33
+ attrs []attribute.KeyValue
34
+ excludeQueryVars bool
35
+ excludeMetrics bool
36
+ recordStackTraceInSpan bool
37
+ queryFormatter func (query string ) string
37
38
}
38
39
39
40
func NewPlugin (opts ... Option ) gorm.Plugin {
@@ -115,7 +116,7 @@ func (p *otelPlugin) after() gormHookFunc {
115
116
if ! span .IsRecording () {
116
117
return
117
118
}
118
- defer span .End ()
119
+ defer span .End (trace . WithStackTrace ( p . recordStackTraceInSpan ) )
119
120
120
121
attrs := make ([]attribute.KeyValue , 0 , len (p .attrs )+ 4 )
121
122
attrs = append (attrs , p .attrs ... )
You can’t perform that action at this time.
0 commit comments