Skip to content

Commit

Permalink
Do not include pkg prefix on default name
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-at-luther committed Feb 8, 2024
1 parent cd88b94 commit 667114c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
20 changes: 0 additions & 20 deletions lisp/x/profiler/funlabeler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,6 @@ func WithFunLabeler(funLabeler FunLabeler) Option {
}
}

// defaultFunName constructs a pretty canonical name using the function name.
// The first return is the package name, and the second is the canonical name.
func defaultFunName(runtime *lisp.Runtime, fun *lisp.LVal) (string, string) {
if fun.Type != lisp.LFun {
return "", ""
}
funData := fun.FunData()
if funData == nil {
return "", ""
}
name := ""
if env := fun.Env(); env != nil {
name = env.GetFunName(fun)
}
if name == "" {
name = getFunNameFromFID(runtime, funData.FID)
}
return funData.Package, name
}

// ELPSDocLabel is a magic string used to extract function labels.
const ELPSDocLabel = `@trace\s*{([^}]+)}`

Expand Down
24 changes: 22 additions & 2 deletions lisp/x/profiler/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,29 @@ func (p *profiler) Start(fun *lisp.LVal) func() {
return func() {}
}

// defaultFunName constructs a pretty canonical name using the function name.
// The first return is the package name, and the second is the canonical name.
func defaultFunName(runtime *lisp.Runtime, fun *lisp.LVal) (string, string) {
if fun.Type != lisp.LFun {
return "", ""
}
funData := fun.FunData()
if funData == nil {
return "", ""
}
name := ""
if env := fun.Env(); env != nil {
name = env.GetFunName(fun)
}
if name == "" {
name = getFunNameFromFID(runtime, funData.FID)
}
return funData.Package, name
}

// prettyFunName returns a pretty name and original name for a fun. If there is
// no pretty name, then the pretty name is the original name.
// no pretty name, then the pretty name is the original name. The pretty name
// includes the package prefix, while the original name does not.
func (p *profiler) prettyFunName(fun *lisp.LVal) (string, string) {
origPkg, origLabel := defaultFunName(p.runtime, fun)
if origLabel == "" {
Expand All @@ -57,7 +78,6 @@ func (p *profiler) prettyFunName(fun *lisp.LVal) (string, string) {
}
if origPkg != "" {
prettyLabel = fmt.Sprintf("%s:%s", origPkg, prettyLabel)
origLabel = fmt.Sprintf("%s:%s", origPkg, origLabel)
}

return prettyLabel, origLabel
Expand Down

0 comments on commit 667114c

Please sign in to comment.