Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
gunlee01 committed Jan 22, 2021
1 parent 84847ff commit f1378b2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion scouterx/strace/tracemain.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ func AddStep(ctx context.Context, step netdata.Step) {
return
}
tctx := tctxmanager.GetTraceContext(ctx)
if tctx == nil {
return
}
tctx.Profile.Add(step)
}

Expand All @@ -117,6 +120,9 @@ func AddMessageStep(ctx context.Context, message string) {
return
}
tctx := tctxmanager.GetTraceContext(ctx)
if tctx == nil {
return
}

step := netdata.NewMessageStep(message, util.MillisToNow(tctx.StartTime))
tctx.Profile.Add(step)
Expand All @@ -128,6 +134,9 @@ func AddHashedMessageStep(ctx context.Context, message string, value, elapsed in
return
}
tctx := tctxmanager.GetTraceContext(ctx)
if tctx == nil {
return
}

step := netdata.NewHashedMessageStep(netio.SendHashedMessage(message), util.MillisToNow(tctx.StartTime))
step.Value = value
Expand All @@ -141,6 +150,9 @@ func AddPMessageStep(ctx context.Context, level netdata.PMessageLevel, message s
return
}
tctx := tctxmanager.GetTraceContext(ctx)
if tctx == nil {
return
}

step := netdata.NewPMessageStep(util.MillisToNow(tctx.StartTime))
step.SetMessage(netio.SendHashedMessage(message), params...)
Expand Down Expand Up @@ -182,6 +194,11 @@ func getRemoteIp(req *http.Request) string {
ip = headerIp
}
}
return ip
}

func normalizeIp(ip string) string {

return strings.Split(ip, ":")[0]
}

Expand Down Expand Up @@ -334,7 +351,7 @@ func startService(ctx context.Context, serviceName, remoteAddr string) (context.

tctx.ServiceName = serviceName
tctx.ServiceHash = netio.SendServiceName(serviceName)
tctx.RemoteIp = remoteAddr
tctx.RemoteIp = normalizeIp(remoteAddr)
return newCtx, tctx
}

Expand Down

0 comments on commit f1378b2

Please sign in to comment.