Last active
October 28, 2021 11:44
-
-
Save wolverian/014ec84815f861135f2a436203d20fef to your computer and use it in GitHub Desktop.
exp/event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"os" | |
"time" | |
"golang.org/x/exp/event" | |
"golang.org/x/exp/event/adapter/logfmt" | |
) | |
func main() { | |
event.SetDefaultExporter(event.NewExporter(logfmt.NewHandler(os.Stdout), nil)) | |
ctx := context.Background() | |
traced(ctx) | |
} | |
func traced(ctx context.Context) { | |
ctx = event.Start(ctx, "traced", event.Bool("ok", true)) | |
defer event.End(ctx) | |
time.Sleep(10 * time.Second) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment