@@ -75,9 +75,13 @@ func (s *sentryClient) CaptureError(err error, context map[string]interface{}) {
7575
7676 hub := sentry .CurrentHub ()
7777 hub .WithScope (func (scope * sentry.Scope ) {
78- // Add context to the scope as extras
79- for key , value := range context {
80- scope .SetExtra (key , value )
78+ if len (context ) > 0 {
79+ // sentry-go v0.46+ removed Scope.SetExtra; attach arbitrary data as a context object.
80+ c := make (sentry.Context , len (context ))
81+ for key , value := range context {
82+ c [key ] = value
83+ }
84+ scope .SetContext ("app" , c )
8185 }
8286 hub .CaptureException (err )
8387 })
@@ -92,8 +96,12 @@ func (s *sentryClient) CaptureMessage(message string, level sentry.Level, contex
9296 hub := sentry .CurrentHub ()
9397 hub .WithScope (func (scope * sentry.Scope ) {
9498 scope .SetLevel (level )
95- for key , value := range context {
96- scope .SetExtra (key , value )
99+ if len (context ) > 0 {
100+ c := make (sentry.Context , len (context ))
101+ for key , value := range context {
102+ c [key ] = value
103+ }
104+ scope .SetContext ("app" , c )
97105 }
98106 hub .CaptureMessage (message )
99107 })
0 commit comments