Skip to content

Commit 4900170

Browse files
authored
Merge pull request #1044 from qazwsxedckll/feat/logging-changes
feat: minor logging changes
2 parents 0cebdef + 101a5f0 commit 4900170

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

actor/deadletter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func NewDeadLetter(actorSystem *ActorSystem) *deadLetterProcess {
4242

4343
if _, isIgnoreDeadLetter := deadLetter.Message.(IgnoreDeadLetterLogging); !isIgnoreDeadLetter {
4444
if shouldThrottle() == Open {
45-
actorSystem.Logger().Debug("[DeadLetter]", slog.Any("pid", deadLetter.PID), slog.Any("message", deadLetter.Message), slog.Any("sender", deadLetter.Sender))
45+
actorSystem.Logger().Info("[DeadLetter]", slog.Any("pid", deadLetter.PID), slog.Any("message", deadLetter.Message), slog.Any("sender", deadLetter.Sender))
4646
}
4747
}
4848
}

actor/throttler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
func NewThrottle(maxEventsInPeriod int32, period time.Duration, throttledCallBack func(int32)) ShouldThrottle {
2424
currentEvents := int32(0)
2525

26-
startTimer := func(duration time.Duration, back func(int32)) {
26+
startTimer := func(duration time.Duration) {
2727
go func() {
2828
// crete ticker to mimic sleep, we do not want to put the goroutine to sleep
2929
// as it will schedule it out of the P making a syscall, we just want it to
@@ -42,7 +42,7 @@ func NewThrottle(maxEventsInPeriod int32, period time.Duration, throttledCallBac
4242
return func() Valve {
4343
tries := atomic.AddInt32(&currentEvents, 1)
4444
if tries == 1 {
45-
startTimer(period, throttledCallBack)
45+
startTimer(period)
4646
}
4747

4848
if tries == maxEventsInPeriod {

cluster/identitylookup/disthash/placement_actor.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package disthash
22

33
import (
4+
"log/slog"
5+
46
"github.com/asynkron/protoactor-go/actor"
57
clustering "github.com/asynkron/protoactor-go/cluster"
6-
"log/slog"
78
)
89

910
type GrainMeta struct {
@@ -35,7 +36,7 @@ func (p *placementActor) Receive(ctx actor.Context) {
3536
case *actor.Stopped:
3637
ctx.Logger().Info("Placement actor stopped")
3738
case *actor.Terminated:
38-
p.onTerminated(msg, ctx)
39+
p.onTerminated(msg)
3940
case *clustering.ActivationRequest:
4041
p.onActivationRequest(msg, ctx)
4142
case *clustering.ClusterTopology:
@@ -45,7 +46,7 @@ func (p *placementActor) Receive(ctx actor.Context) {
4546
}
4647
}
4748

48-
func (p *placementActor) onTerminated(msg *actor.Terminated, ctx actor.Context) {
49+
func (p *placementActor) onTerminated(msg *actor.Terminated) {
4950
found, key, meta := p.pidToMeta(msg.Who)
5051

5152
activationTerminated := &clustering.ActivationTerminated{

cluster/pubsub_topic.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cluster
33
import (
44
"context"
55
"log/slog"
6-
"strings"
76
"time"
87

98
"github.com/asynkron/protoactor-go/actor"
@@ -165,7 +164,7 @@ func (t *TopicActor) logDeliveryErrors(reports []*SubscriberDeliveryReport, logg
165164
for i, report := range reports {
166165
subscribers[i] = report.Subscriber.String()
167166
}
168-
logger.Error("Topic following subscribers could not process the batch", slog.String("topic", t.topic), slog.String("subscribers", strings.Join(subscribers, ",")))
167+
logger.Error("Topic following subscribers could not process the batch", slog.String("topic", t.topic), slog.Any("subscribers", subscribers))
169168
}
170169
}
171170

@@ -227,7 +226,16 @@ func (t *TopicActor) removeSubscribers(subscribersThatLeft []subscribeIdentitySt
227226
delete(t.subscribers, subscriber)
228227
}
229228
if t.shouldThrottle() == actor.Open {
230-
logger.Warn("Topic removed subscribers, because they are dead or they are on members that left the clusterIdentity:", slog.String("topic", t.topic), slog.Any("subscribers", subscribersThatLeft))
229+
// slog json handler cannot print private fields
230+
ids := make([]string, 0, len(subscribersThatLeft))
231+
for _, subscriber := range subscribersThatLeft {
232+
if subscriber.isPID {
233+
ids = append(ids, subscriber.pid.id)
234+
} else {
235+
ids = append(ids, subscriber.clusterIdentity.identity)
236+
}
237+
}
238+
logger.Warn("Topic removed subscribers, because they are dead or they are on members that left the clusterIdentity:", slog.String("topic", t.topic), slog.Any("subscribers", ids))
231239
}
232240
t.saveSubscriptionsInTopicActor(logger)
233241
}

0 commit comments

Comments
 (0)