-
Notifications
You must be signed in to change notification settings - Fork 2
/
extra.go
43 lines (33 loc) · 827 Bytes
/
extra.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package sentry
import "encoding/json"
// Extra allows you to provide additional arbitrary metadata with your
// event. This data is not searchable, but can be invaluable in identifying
// the cause of a problem.
func Extra(extra map[string]interface{}) Option {
if extra == nil {
return nil
}
return &extraOption{extra}
}
type extraOption struct {
extra map[string]interface{}
}
func (o *extraOption) Class() string {
return "extra"
}
func (o *extraOption) Merge(old Option) Option {
if old, ok := old.(*extraOption); ok {
extra := make(map[string]interface{}, len(o.extra))
for k, v := range old.extra {
extra[k] = v
}
for k, v := range o.extra {
extra[k] = v
}
return &extraOption{extra}
}
return o
}
func (o *extraOption) MarshalJSON() ([]byte, error) {
return json.Marshal(o.extra)
}