Skip to content

Commit

Permalink
enhance: refactor printing log
Browse files Browse the repository at this point in the history
Signed-off-by: mingwei <[email protected]>
  • Loading branch information
Victor1319 authored and heymingwei committed Apr 2, 2021
1 parent 91458a6 commit e5f248e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions metanode/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,25 @@ type metadataManager struct {
}

func (m *metadataManager) getPacketLabels(p *Packet) (labels map[string]string) {

labels = make(map[string]string)
labels[exporter.Op] = p.GetOpMsg()

if p.Opcode == proto.OpMetaNodeHeartbeat || p.Opcode == proto.OpCreateMetaPartition {
// no partition info
return
}

mp, err := m.getPartition(p.PartitionID)
if err != nil {
log.LogErrorf("[metaManager] getPacketLabels metric packet: %v, partitions: %v", p, m.partitions)
log.LogWarnf("[metaManager] getPacketLabels metric packet: %v, partitions: %v", p, m.partitions)
return
}

if exporter.EnablePid {
labels[exporter.PartId] = fmt.Sprintf("%d", p.PartitionID)
}
labels[exporter.Vol] = mp.GetBaseConfig().VolName
labels[exporter.Op] = p.GetOpMsg()

return
}
Expand Down
2 changes: 1 addition & 1 deletion util/exporter/consul_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func parseMetaStr(meta string) (bool, map[string]string) {
for _, kv := range kvs {
arr := strings.Split(kv, "=")
if len(arr) != 2 {
log.LogWarnf("meta is invalid, not use %s", meta)
log.LogInfof("meta is invalid, can't use %s", meta)
return false, m
}

Expand Down

0 comments on commit e5f248e

Please sign in to comment.