Skip to content

Commit

Permalink
VERSION 4.1.1
Browse files Browse the repository at this point in the history
n9e mode support debug
  • Loading branch information
freedomkk-qfeng committed Apr 9, 2020
1 parent 6739f87 commit 9876f68
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion g/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
// 4.0.6.2 fix Vendor bug;add remote config api
// 4.0.6.3 fix bugs
// 4.1.0 support n9e transfer mode
// 4.1.1 n9e mode support debug
const (
VERSION = "4.1.0"
VERSION = "4.1.1"
COLLECT_INTERVAL = time.Second
)
31 changes: 31 additions & 0 deletions g/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net"
"net/rpc"
"reflect"
"strings"
"time"

"github.com/didi/nightingale/src/dataobj"
Expand Down Expand Up @@ -37,6 +38,36 @@ func N9ePush(items []*model.MetricValue) {
rpcCodec := codec.MsgpackSpecRpc.ClientCodec(bufconn, &mh)
client := rpc.NewClientWithCodec(rpcCodec)

debug := Config().Debug
debug_endpoints := Config().Debugmetric.Endpoints
debug_items := Config().Debugmetric.Metrics
debug_tags := Config().Debugmetric.Tags
debug_Tags := strings.Split(debug_tags, ",")

if Config().SwitchHosts.Enabled {
hosts := HostConfig().Hosts
for i, metric := range items {
if hostname, ok := hosts[metric.Endpoint]; ok {
items[i].Endpoint = hostname
}
}
}

if debug {
for _, metric := range items {
metric_tags := strings.Split(metric.Tags, ",")
if in_array(metric.Endpoint, debug_endpoints) && in_array(metric.Metric, debug_items) {
if debug_tags == "" {
log.Printf("=> <Total=%d> %v\n", len(items), metric)
continue
}
if array_include(debug_Tags, metric_tags) {
log.Printf("=> <Total=%d> %v\n", len(items), metric)
}
}
}
}

var reply dataobj.TransferResp
err = client.Call("Transfer.Push", items, &reply)
client.Close()
Expand Down

0 comments on commit 9876f68

Please sign in to comment.