@@ -3,6 +3,7 @@ package redis
33import (
44 "context"
55 "fmt"
6+ "sort"
67 "strings"
78 "sync"
89 "time"
@@ -571,6 +572,9 @@ type channel struct {
571572 chanSize int
572573 chanSendTimeout time.Duration
573574 checkInterval time.Duration
575+
576+ subscriptions map [string ]struct {}
577+ subscriptionsMu sync.RWMutex
574578}
575579
576580func newChannel (pubSub * PubSub , opts ... ChannelOption ) * channel {
@@ -580,6 +584,8 @@ func newChannel(pubSub *PubSub, opts ...ChannelOption) *channel {
580584 chanSize : 100 ,
581585 chanSendTimeout : time .Minute ,
582586 checkInterval : 3 * time .Second ,
587+
588+ subscriptions : make (map [string ]struct {}),
583589 }
584590 for _ , opt := range opts {
585591 opt (c )
@@ -618,6 +624,20 @@ func (c *channel) initHealthCheck() {
618624 }()
619625}
620626
627+ // Helper function to format subscription information
628+ func (c * channel ) getSubscriptionInfo () string {
629+ if len (c .subscriptions ) == 0 {
630+ return "none"
631+ }
632+
633+ subs := make ([]string , 0 , len (c .subscriptions ))
634+ for sub := range c .subscriptions {
635+ subs = append (subs , sub )
636+ }
637+ sort .Strings (subs ) // Sort for consistent output
638+ return strings .Join (subs , ", " )
639+ }
640+
621641// initMsgChan must be in sync with initAllChan.
622642func (c * channel ) initMsgChan () {
623643 ctx := context .TODO ()
@@ -663,9 +683,13 @@ func (c *channel) initMsgChan() {
663683 <- timer .C
664684 }
665685 case <- timer .C :
686+ c .subscriptionsMu .RLock ()
687+ subInfo := c .getSubscriptionInfo ()
688+ c .subscriptionsMu .RUnlock ()
689+
666690 internal .Logger .Printf (
667- ctx , "redis: %s channel is full for %s (message is dropped)" ,
668- c , c .chanSendTimeout )
691+ ctx , "redis: Channel is full for %s (message is dropped), subscriptions: %s " ,
692+ c .chanSendTimeout , subInfo )
669693 }
670694 default :
671695 internal .Logger .Printf (ctx , "redis: unknown message type: %T" , msg )
@@ -717,9 +741,13 @@ func (c *channel) initAllChan() {
717741 <- timer .C
718742 }
719743 case <- timer .C :
744+ c .subscriptionsMu .RLock ()
745+ subInfo := c .getSubscriptionInfo ()
746+ c .subscriptionsMu .RUnlock ()
747+
720748 internal .Logger .Printf (
721- ctx , "redis: %s channel is full for %s (message is dropped)" ,
722- c , c .chanSendTimeout )
749+ ctx , "redis: Channel is full for %s (message is dropped), subscriptions: %s " ,
750+ c .chanSendTimeout , subInfo )
723751 }
724752 default :
725753 internal .Logger .Printf (ctx , "redis: unknown message type: %T" , msg )
0 commit comments