Documentation ¶
Index ¶
- func DebugLog(ctx context.Context, args ...interface{})
- func DebugLogf(ctx context.Context, format string, args ...interface{})
- func DebugTag(ctx context.Context, k string, v interface{})
- func Finish(ctx context.Context)
- func IsDebug(ctx context.Context) bool
- func Log(ctx context.Context, args ...interface{})
- func Logf(ctx context.Context, format string, args ...interface{})
- func SetDebug(ctx context.Context) context.Context
- func Start(ctx context.Context, name string) context.Context
- func StartChild(ctx context.Context, name string) context.Context
- func Tag(ctx context.Context, k string, v interface{})
- type Tracer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Log ¶
Log add a log to a tracer context using Sprint
Example ¶
ctx := Start(context.Background(), "name") Log(ctx, "a ", "b") fmt.Printf("%#v\n", Get(ctx).Logs) Logf(ctx, "a %s", "b") fmt.Printf("%#v\n", Get(ctx).Logs) DebugLog(ctx, "a ", "b") DebugLogf(ctx, "a %s", "b") fmt.Printf("%#v\n", Get(ctx).Logs) ctx = SetDebug(ctx) DebugLog(ctx, "a ", "b") DebugLogf(ctx, "a %s", "b") fmt.Printf("%#v\n", Get(ctx).Logs)
Output: []string{"a b"} []string{"a b", "a b"} []string{"a b", "a b"} []string{"a b", "a b", "a b", "a b"}
func Start ¶
Start start a new tracer on the given context
Example ¶
ctx := Start(context.Background(), "name") Start(ctx, "child1") Start(ctx, "child2") Finish(ctx) tracer := Get(ctx) fmt.Println( tracer.Name, !tracer.At.IsZero(), tracer.Duration > 0, tracer.Tags, tracer.Logs, len(tracer.Children), tracer.Children[0].Name, tracer.Children[1].Name, )
Output: name true true map[] [] 2 child1 child2
func StartChild ¶
Start start a child tracer on the given context
func Tag ¶
Tag add a tag to a tracer context
Example ¶
ctx := Start(context.Background(), "name") Tag(ctx, "k", "v") fmt.Println(Get(ctx).Tags) DebugTag(ctx, "debugKey", "debugValue") fmt.Println(Get(ctx).Tags) ctx = SetDebug(ctx) DebugTag(ctx, "debugKey", "debugValue") fmt.Println(Get(ctx).Tags)
Output: map[k:v] map[k:v] map[debugKey:debugValue k:v]
Types ¶
Click to show internal directories.
Click to hide internal directories.