Skip to content

Commit 8b0ded1

Browse files
committed
misc
1 parent 767165e commit 8b0ded1

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

scouterx/strace/tracemain.go

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,16 +407,33 @@ func findXLogDiscard(tctx *netio.TraceContext, elapsed int32) netdata.XlogDiscar
407407
}
408408

409409
func StartMethod(ctx context.Context) *netdata.MethodStep {
410-
return startMethodWithParam(ctx)
410+
defer common.ReportScouterPanic()
411+
return startMethodWithParam(ctx) //do not call StartMethodWithParam (because of method name finding depth)
411412
}
412413

413414
func StartMethodWithParam(ctx context.Context, params ...interface{}) *netdata.MethodStep {
415+
defer common.ReportScouterPanic()
414416
return startMethodWithParam(ctx, params)
415417
}
416418

417-
func startMethodWithParam(ctx context.Context, params ...interface{}) *netdata.MethodStep {
419+
func StartCustomMethod(ctx context.Context, methodName string) *netdata.MethodStep {
420+
return StartCustomMethodWithParam(ctx, methodName)
421+
}
422+
423+
func StartCustomMethodWithParam(ctx context.Context, methodName string, params ...interface{}) *netdata.MethodStep {
418424
defer common.ReportScouterPanic()
425+
if ctx == nil {
426+
return nil
427+
}
428+
tctx := tctxmanager.GetTraceContext(ctx)
429+
if tctx == nil {
430+
return nil
431+
}
432+
433+
return startMethodWithParam0(tctx, methodName, methodName, params)
434+
}
419435

436+
func startMethodWithParam(ctx context.Context, params ...interface{}) *netdata.MethodStep {
420437
if ctx == nil {
421438
return nil
422439
}
@@ -428,13 +445,17 @@ func startMethodWithParam(ctx context.Context, params ...interface{}) *netdata.M
428445
pc, _, _, _ := runtime.Caller(2)
429446
funcName := fmt.Sprintf("%s", runtime.FuncForPC(pc).Name())
430447
split := strings.Split(funcName, "/")
431-
shortName := split[len(split)-1] + "()"
448+
methodName := split[len(split)-1] + "()"
449+
450+
return startMethodWithParam0(tctx, funcName, methodName, params)
451+
}
432452

453+
func startMethodWithParam0(tctx *netio.TraceContext, funcName string, methodName string, params ...interface{}) *netdata.MethodStep {
433454
addMessageStepIfParamExist(tctx, params)
434455
tctx.LastMethod = funcName
435456

436457
step := netdata.NewMethodStep()
437-
step.Hash = netio.SendMethod(shortName)
458+
step.Hash = netio.SendMethod(methodName)
438459
step.StartTime = util.MillisToNow(tctx.StartTime)
439460
tctx.Profile.Push(step)
440461
return step

0 commit comments

Comments
 (0)