Skip to content

Commit

Permalink
all: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
egonelbre authored and zeebo committed Aug 14, 2024
1 parent 43deb40 commit 369df41
Show file tree
Hide file tree
Showing 12 changed files with 354 additions and 361 deletions.
15 changes: 9 additions & 6 deletions callers.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ func callerFunc(frames int) string {
// extractFuncName splits fully qualified function name:
//
// Input:
// "github.com/spacemonkeygo/monkit/v3.BenchmarkTask.func1"
// "main.DoThings.func1"
// "main.DoThings"
//
// "github.com/spacemonkeygo/monkit/v3.BenchmarkTask.func1"
// "main.DoThings.func1"
// "main.DoThings"
//
// Output:
// funcname: "BenchmarkTask.func1"
// funcname: "DoThings.func1"
// funcname: "DoThings"
//
// funcname: "BenchmarkTask.func1"
// funcname: "DoThings.func1"
// funcname: "DoThings"
func extractFuncName(fullyQualifiedName string) (funcname string, ok bool) {
lastSlashPos := strings.LastIndexByte(fullyQualifiedName, '/')
if lastSlashPos+1 >= len(fullyQualifiedName) {
Expand Down
9 changes: 4 additions & 5 deletions counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ import (
// may be more convenient to use the Counter accessor on a given Scope.
// Expected creation is like:
//
// var mon = monkit.Package()
//
// func MyFunc() {
// mon.Counter("beans").Inc(1)
// }
// var mon = monkit.Package()
//
// func MyFunc() {
// mon.Counter("beans").Inc(1)
// }
type Counter struct {
mtx sync.Mutex
val, low, high int64
Expand Down
46 changes: 23 additions & 23 deletions ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,34 +168,34 @@ type Task func(ctx *context.Context, args ...interface{}) func(*error)
// It also adds a new Span to the given ctx during execution. Expected usage
// like:
//
// var mon = monkit.Package()
// var mon = monkit.Package()
//
// func MyFunc(ctx context.Context, arg1, arg2 string) (err error) {
// defer mon.Task()(&ctx, arg1, arg2)(&err)
// ...
// }
// func MyFunc(ctx context.Context, arg1, arg2 string) (err error) {
// defer mon.Task()(&ctx, arg1, arg2)(&err)
// ...
// }
//
// or
//
// var (
// mon = monkit.Package()
// funcTask = mon.Task()
// )
// var (
// mon = monkit.Package()
// funcTask = mon.Task()
// )
//
// func MyFunc(ctx context.Context, arg1, arg2 string) (err error) {
// defer funcTask(&ctx, arg1, arg2)(&err)
// ...
// }
// func MyFunc(ctx context.Context, arg1, arg2 string) (err error) {
// defer funcTask(&ctx, arg1, arg2)(&err)
// ...
// }
//
// Task allows you to include SeriesTags. WARNING: Each unique tag key/value
// combination creates a unique Func and a unique series. SeriesTags should
// only be used for low-cardinality values that you intentionally wish to
// result in a unique series. Example:
//
// func MyFunc(ctx context.Context, arg1, arg2 string) (err error) {
// defer mon.Task(monkit.NewSeriesTag("key1", "val1"))(&ctx)(&err)
// ...
// }
// func MyFunc(ctx context.Context, arg1, arg2 string) (err error) {
// defer mon.Task(monkit.NewSeriesTag("key1", "val1"))(&ctx)(&err)
// ...
// }
//
// Task uses runtime.Caller to determine the associated Func name. See
// TaskNamed if you want to supply your own name. See Func.Task if you already
Expand Down Expand Up @@ -226,13 +226,13 @@ func (s *Scope) Task(tags ...SeriesTag) Task {
// Task returns a new Task for use on this Func. It also adds a new Span to
// the given ctx during execution.
//
// var mon = monkit.Package()
// var mon = monkit.Package()
//
// func MyFunc(ctx context.Context, arg1, arg2 string) (err error) {
// f := mon.Func()
// defer f.Task(&ctx, arg1, arg2)(&err)
// ...
// }
// func MyFunc(ctx context.Context, arg1, arg2 string) (err error) {
// f := mon.Func()
// defer f.Task(&ctx, arg1, arg2)(&err)
// ...
// }
//
// It's more expected for you to use mon.Task directly. See RemoteTrace or
// ResetTrace if you want greater control over creating new traces.
Expand Down
Loading

0 comments on commit 369df41

Please sign in to comment.