Skip to content

Commit 4999601

Browse files
committed
feat: add custom event
add custom event add custom event
1 parent 3238db3 commit 4999601

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cmd/main.go

+14
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ func main() {
3939
// Run a simple function
4040
print()
4141

42+
// Run record events
43+
recordEvents()
4244
// Wait for shut down to ensure data gets flushed
4345
nrApp.Shutdown(5 * time.Second)
4446
}
@@ -51,3 +53,15 @@ func print() {
5153
defer txn.End()
5254
fmt.Println("Hello world! Welcome to your first instrumented Golang App!")
5355
}
56+
57+
func recordEvents() {
58+
tasks := []string{"white", "black", "red", "blue", "green", "yello"}
59+
for _, task := range tasks {
60+
txn := nrApp.StartTransaction("task")
61+
time.Sleep(10 * time.Millisecond)
62+
txn.End()
63+
nrApp.RecordCustomEvent("task", map[string]any{
64+
"color": task,
65+
})
66+
}
67+
}

0 commit comments

Comments
 (0)