Skip to content

Instantly share code, notes, and snippets.

@maplebed
Last active September 17, 2019 21:22
Show Gist options
  • Save maplebed/5409aa83cc816eb53268661ff20a8df2 to your computer and use it in GitHub Desktop.
Save maplebed/5409aa83cc816eb53268661ff20a8df2 to your computer and use it in GitHub Desktop.
inserts a bunch of columns to a dataset, thwacking the DB insertion code into leaking something.
package main
import (
"fmt"
"sync"
libhoney "github.com/honeycombio/libhoney-go"
"github.com/honeycombio/libhoney-go/transmission"
)
func main() {
libhoney.Init(libhoney.Config{
APIHost: "https://api-dogfood.honeycomb.io",
APIKey: "abcabc123123abcabc123123",
Dataset: "bencols2",
MaxBatchSize: 5,
})
wg := sync.WaitGroup{}
wg.Add(1)
go readResponses(&wg, libhoney.TxResponses())
for numTimes := 0; numTimes < 10; numTimes++ {
for i := 0; i < 50; i++ {
ev := libhoney.NewEvent()
for j := 0; j < 100; j++ {
ev.AddField(fmt.Sprintf("%dgocol%d", i, j), j)
}
fmt.Printf("sending ev %d\n", numTimes)
ev.Metadata = fmt.Sprintf("%d", i)
ev.Send()
}
}
libhoney.Close()
wg.Wait()
}
func readResponses(wg *sync.WaitGroup, responses chan transmission.Response) {
// responses will be closed when libhoney is closed
for r := range responses {
if r.StatusCode >= 200 && r.StatusCode < 300 {
id := r.Metadata.(string)
fmt.Printf("Successfully sent event %s to Honeycomb\n", id)
} else {
fmt.Printf("Error sending event to Honeycomb! Code %d, err %v, duration %f, and response body %s\n",
r.StatusCode, r.Err, r.Duration, r.Body)
}
}
wg.Done()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment