Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
gunlee01 committed Jan 17, 2021
1 parent 9734f7d commit 767165e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
11 changes: 7 additions & 4 deletions scouterx/netio/tracecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
)

type TraceContext struct {
Closed bool
LastMethod string
IsStream bool
Closed bool
LastMethod string
IsStream bool

Inherit bool
Inherit bool
InheritStartTime time.Time

Goid int
Expand Down Expand Up @@ -42,6 +42,7 @@ type TraceContext struct {
SqlTime int32
Sqltext string

Status int32
ApicallName string
ApicallCount int32
ApicallTime int32
Expand Down Expand Up @@ -99,6 +100,8 @@ func (tctx (TraceContext)) ToXlog(discardType netdata.XlogDiscardType, elapsed i
xlog.HasDump = 0
xlog.Error = tctx.Error

xlog.Status = tctx.Status

xlog.DiscardType = discardType
xlog.ProfileSize = int32(tctx.ProfileSize)
xlog.ProfileCount = int32(tctx.ProfileCount)
Expand Down
21 changes: 16 additions & 5 deletions scouterx/strace/tracemain.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func AddPMessageStep(ctx context.Context, level netdata.PMessageLevel, message s
tctx.Profile.Add(step)
}

func StartHttpService(ctx context.Context, req http.Request) (newCtx context.Context) {
func StartHttpService(ctx context.Context, req *http.Request) (newCtx context.Context) {
defer common.ReportScouterPanic()
if ctx == nil {
return context.Background()
Expand All @@ -174,7 +174,7 @@ func StartHttpService(ctx context.Context, req http.Request) (newCtx context.Con
return newCtx
}

func getRemoteIp(req http.Request) string {
func getRemoteIp(req *http.Request) string {
ip := req.RemoteAddr
if ac.TraceHttpClientIpHeaderKey != "" {
headerIp := req.Header.Get(ac.TraceHttpClientIpHeaderKey)
Expand All @@ -185,9 +185,20 @@ func getRemoteIp(req http.Request) string {
return strings.Split(ip, ":")[0]
}

func EndHttpService(ctx context.Context, req http.Request, res http.Response) {
//TODO body (of specific service) profile from req.body
func EndHttpService(ctx context.Context, req *http.Request, res *http.Response) {
common.ReportScouterPanic()
//TODO body (of specific service) profile from req.body

if res != nil {
if ctx == nil {
return
}
tctx := tctxmanager.GetTraceContext(ctx)
if tctx == nil || tctx.Closed {
return
}
tctx.Status = int32(res.StatusCode)
}
endAnyService(ctx)
}

Expand Down Expand Up @@ -454,7 +465,7 @@ func EndMethod(ctx context.Context, step *netdata.MethodStep) {
tctx.Profile.Pop(step)
}

func profileHttpHeaders(r http.Request, tctx *netio.TraceContext) {
func profileHttpHeaders(r *http.Request, tctx *netio.TraceContext) {
startTime := util.MillisToNow(tctx.StartTime)
if ac.ProfileHttpHeaderEnabled {
notAll := len(ac.ProfileHttpHeaderKeys) > 0
Expand Down

0 comments on commit 767165e

Please sign in to comment.