File tree 5 files changed +43
-5
lines changed 5 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -648,11 +648,20 @@ func (i *Incident) getRecipientsChannel(t time.Time) rule.ContactChannels {
648
648
}
649
649
650
650
if i .IsNotifiable (state .Role ) {
651
- for _ , contact := range r .GetContactsAt (t ) {
652
- if contactChs [contact ] == nil {
653
- contactChs [contact ] = make (map [int64 ]bool )
654
- contactChs [contact ][contact.DefaultChannelID ] = true
651
+ contacts := r .GetContactsAt (t )
652
+ if len (contacts ) > 0 {
653
+ i .logger .Debugw ("Expanded recipient to contacts" ,
654
+ zap .Object ("recipient" , r ),
655
+ zap .Objects ("contacts" , contacts ))
656
+
657
+ for _ , contact := range contacts {
658
+ if contactChs [contact ] == nil {
659
+ contactChs [contact ] = make (map [int64 ]bool )
660
+ contactChs [contact ][contact.DefaultChannelID ] = true
661
+ }
655
662
}
663
+ } else {
664
+ i .logger .Warnw ("Recipient expanded to no contacts" , zap .Object ("recipient" , r ))
656
665
}
657
666
}
658
667
}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package recipient
2
2
3
3
import (
4
4
"database/sql"
5
+ "go.uber.org/zap/zapcore"
5
6
"time"
6
7
)
7
8
@@ -21,6 +22,14 @@ func (c *Contact) GetContactsAt(t time.Time) []*Contact {
21
22
return []* Contact {c }
22
23
}
23
24
25
+ // MarshalLogObject implements the zapcore.ObjectMarshaler interface.
26
+ func (c * Contact ) MarshalLogObject (encoder zapcore.ObjectEncoder ) error {
27
+ // Use contact_id as key so that the type is explicit if logged as the Recipient interface.
28
+ encoder .AddInt64 ("contact_id" , c .ID )
29
+ encoder .AddString ("name" , c .FullName )
30
+ return nil
31
+ }
32
+
24
33
var _ Recipient = (* Contact )(nil )
25
34
26
35
type Address struct {
Original file line number Diff line number Diff line change 1
1
package recipient
2
2
3
- import "time"
3
+ import (
4
+ "go.uber.org/zap/zapcore"
5
+ "time"
6
+ )
4
7
5
8
type Group struct {
6
9
ID int64 `db:"id"`
@@ -21,4 +24,12 @@ func (g *Group) String() string {
21
24
return g .Name
22
25
}
23
26
27
+ // MarshalLogObject implements the zapcore.ObjectMarshaler interface.
28
+ func (g * Group ) MarshalLogObject (encoder zapcore.ObjectEncoder ) error {
29
+ // Use contact_id as key so that the type is explicit if logged as the Recipient interface.
30
+ encoder .AddInt64 ("group_id" , g .ID )
31
+ encoder .AddString ("name" , g .Name )
32
+ return nil
33
+ }
34
+
24
35
var _ Recipient = (* Group )(nil )
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
11
11
type Recipient interface {
12
12
fmt.Stringer
13
+ zapcore.ObjectMarshaler
13
14
14
15
GetContactsAt (t time.Time ) []* Contact
15
16
}
Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ func (s *Schedule) RefreshRotations() {
23
23
s .rotationResolver .update (s .Rotations )
24
24
}
25
25
26
+ // MarshalLogObject implements the zapcore.ObjectMarshaler interface.
27
+ func (s * Schedule ) MarshalLogObject (encoder zapcore.ObjectEncoder ) error {
28
+ // Use schedule_id as key so that the type is explicit if logged as the Recipient interface.
29
+ encoder .AddInt64 ("schedule_id" , s .ID )
30
+ encoder .AddString ("name" , s .Name )
31
+ return nil
32
+ }
33
+
26
34
type Rotation struct {
27
35
ID int64 `db:"id"`
28
36
ScheduleID int64 `db:"schedule_id"`
You can’t perform that action at this time.
0 commit comments