Skip to content

Commit

Permalink
Adding topics of the group in log
Browse files Browse the repository at this point in the history
  • Loading branch information
sciclon2 committed Sep 7, 2024
1 parent 2a57bd8 commit 097a55b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pkg/metrics/metrics_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"strconv"
"strings"
"sync"

"github.com/redis/go-redis/v9"
Expand Down Expand Up @@ -37,9 +38,12 @@ func (lp *LagProcessor) processGroup(group *structs.Group) {
// Set the group's sum values
lp.updateGroupSums(group, tempSumLagInOffsets, tempSumLagInSeconds, validOffsetsFound, validSecondsFound)

logrus.Infof("Finished processing group in cluster: %s, Group: %s, MaxLagInOffsets: %d, MaxLagInSeconds: %d, SumLagInOffsets: %d, SumLagInSeconds: %d",
group.ClusterName, group.Name, group.MaxLagInOffsets, group.MaxLagInSeconds, group.SumLagInOffsets, group.SumLagInSeconds)
// Use the helper function to get the concatenated topic names
topicList := concatenateTopicNames(group)

// Include the topics in the log message
logrus.Infof("Finished processing group in cluster: %s, Group: %s, MaxLagInOffsets: %d, MaxLagInSeconds: %d, SumLagInOffsets: %d, SumLagInSeconds: %d, Topics: [%s]",
group.ClusterName, group.Name, group.MaxLagInOffsets, group.MaxLagInSeconds, group.SumLagInOffsets, group.SumLagInSeconds, topicList)
}

func (lp *LagProcessor) processTopic(topic *structs.Topic, group *structs.Group, tempSumLagInOffsets, tempSumLagInSeconds *int64, validOffsetsFound, validSecondsFound *bool) {
Expand Down Expand Up @@ -333,3 +337,12 @@ func (lp *LagProcessor) GenerateMetrics(groupsComplete <-chan *structs.Group, nu

return metricsToExportChan
}

// concatenateTopicNames takes a group and returns a concatenated string of topic names.
func concatenateTopicNames(group *structs.Group) string {
var topicNames []string
for _, topic := range group.Topics {
topicNames = append(topicNames, topic.Name)
}
return strings.Join(topicNames, ", ")
}

0 comments on commit 097a55b

Please sign in to comment.