Skip to content

Commit

Permalink
Use the full, cleaned up module name
Browse files Browse the repository at this point in the history
  • Loading branch information
gagbo committed Oct 11, 2023
1 parent 7a45333 commit 49361fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ versioning](https://go.dev/doc/modules/version-numbers).

### Changed

- [All] autometrics now reports the fully qualified package name and cleans up the pointer
specifiers from reported pointer receiver methods

### Deprecated

### Removed
Expand Down
11 changes: 5 additions & 6 deletions pkg/autometrics/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ func CallerInfo() (callInfo CallInfo) {
if index == -1 {
callInfo.FuncName = functionName
} else {
moduleIndex := strings.LastIndex(functionName[:index], ".")
if moduleIndex == -1 {
callInfo.ModuleName = functionName[:index]
} else {
callInfo.ModuleName = functionName[moduleIndex+1 : index]
}
callInfo.ModuleName = strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(
functionName[:index],
"(", ""),
")", ""),
"*", "")

callInfo.FuncName = functionName[index+1:]
}
Expand Down

0 comments on commit 49361fa

Please sign in to comment.