Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(keeper): modify log and optimize code #29493

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor(keeper): modify log and optimize code
  • Loading branch information
qevolg committed Jan 6, 2025
commit 57e48a5ae613961ef835f6b8200e95eba98b5c66
2 changes: 1 addition & 1 deletion tools/keeper/api/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func (r *Reporter) handlerFunc() gin.HandlerFunc {

logger.Tracef("report data:%s", string(data))
if e := json.Unmarshal(data, &report); e != nil {
logger.Errorf("error occurred while unmarshal request, data:%s, error:%s", data, err)
logger.Errorf("error occurred while unmarshal request, data:%s, error:%v", data, e)
return
}
var sqls []string
Expand Down
6 changes: 2 additions & 4 deletions tools/keeper/cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewCommand(conf *config.Config) *Command {
panic(err)
}

imp := &Command{
return &Command{
client: client,
conn: conn,
username: conf.TDengine.Username,
Expand All @@ -70,7 +70,6 @@ func NewCommand(conf *config.Config) *Command {
RawQuery: fmt.Sprintf("db=%s&precision=ms", conf.Metrics.Database.Name),
},
}
return imp
}

func (cmd *Command) Process(conf *config.Config) {
Expand Down Expand Up @@ -101,7 +100,7 @@ func (cmd *Command) Process(conf *config.Config) {
}

func (cmd *Command) ProcessTransfer(conf *config.Config) {
fromTime, err := time.Parse("2006-01-02T15:04:05Z07:00", conf.FromTime)
fromTime, err := time.Parse(time.RFC3339, conf.FromTime)
if err != nil {
logger.Errorf("parse fromTime error, msg:%s", err)
return
Expand Down Expand Up @@ -401,7 +400,6 @@ func (cmd *Command) TransferTaosdClusterBasicInfo() error {

// cluster_info
func (cmd *Command) TransferTableToDst(sql string, dstTable string, tagNum int) error {

ctx := context.Background()

endTime := time.Now()
Expand Down
14 changes: 6 additions & 8 deletions tools/keeper/monitor/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,31 @@ func (s *sysMonitor) collect() {
}

s.Lock()
defer s.Unlock()

for output := range s.outputs {
select {
case output <- *s.status:
default:
}
}
s.Unlock()
}

func (s *sysMonitor) Register(c chan<- SysStatus) {
s.Lock()
defer s.Unlock()
if s.outputs == nil {
s.outputs = map[chan<- SysStatus]struct{}{
c: {},
}
} else {
s.outputs[c] = struct{}{}
s.outputs = map[chan<- SysStatus]struct{}{}
}
s.Unlock()
s.outputs[c] = struct{}{}
}

func (s *sysMonitor) Deregister(c chan<- SysStatus) {
s.Lock()
defer s.Unlock()
if s.outputs != nil {
delete(s.outputs, c)
}
s.Unlock()
}

var SysMonitor = &sysMonitor{status: &SysStatus{}}
Expand Down
Loading