Skip to content

Commit

Permalink
feat: monitor use log level info (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
crimson-gao authored Jan 24, 2025
1 parent 0a73cef commit 2cb7e56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion consumer/shard_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
sls "github.com/aliyun/aliyun-log-go-sdk"
"github.com/aliyun/aliyun-log-go-sdk/internal"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
)

type MonitorMetrics struct {
Expand Down Expand Up @@ -68,7 +69,7 @@ func (m *ShardMonitor) shouldReport() bool {
func (m *ShardMonitor) reportByLogger(logger log.Logger) {
m.lastReportTime = time.Now()
metrics := m.getAndResetMetrics()
logger.Log("msg", "report status",
level.Info(logger).Log("msg", "report status",
"fetchFailed", metrics.fetchReqFailedCount.Load(),
"logRawSize", metrics.logRawSize.Load(),
"processFailed", metrics.processFailedCount.Load(),
Expand Down
3 changes: 2 additions & 1 deletion producer/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/aliyun/aliyun-log-go-sdk/internal"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
)

type ProducerMetrics struct {
Expand Down Expand Up @@ -74,7 +75,7 @@ func (m *ProducerMonitor) reportThread(reportInterval time.Duration, logger log.
ticker := time.NewTicker(reportInterval)
for range ticker.C {
metrics := m.getAndResetMetrics()
logger.Log("msg", "report status",
level.Info(logger).Log("msg", "report status",
"sendBatch", metrics.sendBatch.String(),
"retryCount", metrics.retryCount.Load(),
"createBatch", metrics.createBatch.Load(),
Expand Down

0 comments on commit 2cb7e56

Please sign in to comment.