diff --git a/go.mod b/go.mod index 76fb40437..ce1f5ee99 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/hashicorp/terraform-json v0.14.0 github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e - github.com/honeycombio/libhoney-go v1.17.0 + github.com/honeycombio/libhoney-go v1.18.0 github.com/imdario/mergo v0.3.13 github.com/kyokomi/emoji/v2 v2.2.10 github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index 9da93b6d4..b6f631320 100644 --- a/go.sum +++ b/go.sum @@ -277,8 +277,8 @@ github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c h1:kp3AxgXgDOmIJFR7b github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A= github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e h1:0aewS5NTyxftZHSnFaJmWE5oCCrj4DyEXkAiMa1iZJM= github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= -github.com/honeycombio/libhoney-go v1.17.0 h1:e/s52AcMytDCIobAfThj82mWqSYdPV+djhCs4dKxxnU= -github.com/honeycombio/libhoney-go v1.17.0/go.mod h1:KwbcXkqUbH20x3MpfSt/kdvlog3FFdEnouqYD3XKXLY= +github.com/honeycombio/libhoney-go v1.18.0 h1:OYHOP381r3Ea76BhUYeza8PUTMDp8MByoOxDn3qtEq8= +github.com/honeycombio/libhoney-go v1.18.0/go.mod h1:KwbcXkqUbH20x3MpfSt/kdvlog3FFdEnouqYD3XKXLY= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= diff --git a/vendor/github.com/honeycombio/libhoney-go/.gitignore b/vendor/github.com/honeycombio/libhoney-go/.gitignore index 826b5e56c..dec8a3cdb 100644 --- a/vendor/github.com/honeycombio/libhoney-go/.gitignore +++ b/vendor/github.com/honeycombio/libhoney-go/.gitignore @@ -1,6 +1,9 @@ # Example artifacts examples/wiki-manual-tracing/*.txt +# Test report +unit-tests.xml + # Compiled Object files, Static and Dynamic libs (Shared Objects) *.o *.a diff --git a/vendor/github.com/honeycombio/libhoney-go/CHANGELOG.md b/vendor/github.com/honeycombio/libhoney-go/CHANGELOG.md index 085e421a8..a2a436628 100644 --- a/vendor/github.com/honeycombio/libhoney-go/CHANGELOG.md +++ b/vendor/github.com/honeycombio/libhoney-go/CHANGELOG.md @@ -1,5 +1,26 @@ # libhoney Changelog +## 1.18.0 2022-10-28 + +### Enhancements + +- include Go version, GOOS, & GOARCH in user-agent (#207) | @robbkidd + +### Maintenance + +- Convert stray fmt.Printf into logger.Printf (#203) | @glenjamin + +## 1.17.1 2022-10-19 + +### Fixed + +- Pre-define field map capacities (#197) | [lizthegrey](https://github.com/lizthegrey) + +### Maintenance + +- Add release file (#199) | [@vreynolds](https://github.com/vreynolds) +- Add new project workflow (#196) | [@vreynolds](https://github.com/vreynolds) + ## 1.17.0 2022-09-23 ### Enhancements diff --git a/vendor/github.com/honeycombio/libhoney-go/Makefile b/vendor/github.com/honeycombio/libhoney-go/Makefile new file mode 100644 index 000000000..0a75fff2c --- /dev/null +++ b/vendor/github.com/honeycombio/libhoney-go/Makefile @@ -0,0 +1,11 @@ +.PHONY: test +#: run the tests! +test: +ifeq (, $(shell which gotestsum)) + @echo " ***" + @echo "Running with standard go test because gotestsum was not found on PATH. Consider installing gotestsum for friendlier test output!" + @echo " ***" + go test -race -v ./... +else + gotestsum --junitfile unit-tests.xml --format testname -- -race ./... +endif diff --git a/vendor/github.com/honeycombio/libhoney-go/RELEASING.md b/vendor/github.com/honeycombio/libhoney-go/RELEASING.md index 148459391..b5aec96c1 100644 --- a/vendor/github.com/honeycombio/libhoney-go/RELEASING.md +++ b/vendor/github.com/honeycombio/libhoney-go/RELEASING.md @@ -1,6 +1,6 @@ # Creating a new release -1. Update the version string in `libhoney.go`. +1. Update the Version string in `version/version.go`. 2. Add new release notes to the Changelog. 3. Open a PR with above changes. 4. Once the above PR is merged, tag `main` with the new version, e.g. `v0.1.1`. Push the tags. This will kick off a CI workflow, which will publish a draft GitHub release. diff --git a/vendor/github.com/honeycombio/libhoney-go/libhoney.go b/vendor/github.com/honeycombio/libhoney-go/libhoney.go index 083ea11ef..aff02b355 100644 --- a/vendor/github.com/honeycombio/libhoney-go/libhoney.go +++ b/vendor/github.com/honeycombio/libhoney-go/libhoney.go @@ -27,7 +27,6 @@ import ( func init() { rand.Seed(time.Now().UnixNano()) - transmission.Version = version } const ( @@ -35,7 +34,6 @@ const ( defaultAPIHost = "https://api.honeycomb.io/" defaultClassicDataset = "libhoney-go dataset" defaultDataset = "unknown_dataset" - version = "1.17.0" // DefaultMaxBatchSize how many events to collect in a batch DefaultMaxBatchSize = 50 @@ -538,9 +536,10 @@ func Flush() { // Contrary to its name, SendNow does not block and send data // immediately, but only enqueues to be sent asynchronously. // It is equivalent to: -// ev := libhoney.NewEvent() -// ev.Add(data) -// ev.Send() +// +// ev := libhoney.NewEvent() +// ev.Add(data) +// ev.Send() // // Deprecated: SendNow is deprecated and may be removed in a future major release. func SendNow(data interface{}) error { @@ -844,8 +843,8 @@ func (e *Event) SendPresampled() (err error) { e.sendLock.Lock() defer e.sendLock.Unlock() - e.fieldHolder.lock.RLock() - defer e.fieldHolder.lock.RUnlock() + e.lock.RLock() + defer e.lock.RUnlock() if len(e.data) == 0 { return errors.New("No metrics added to event. Won't send empty event.") } @@ -922,9 +921,10 @@ func (b *Builder) AddDynamicField(name string, fn func() interface{}) error { // Contrary to its name, SendNow does not block and send data // immediately, but only enqueues to be sent asynchronously. // It is equivalent to: -// ev := builder.NewEvent() -// ev.Add(data) -// ev.Send() +// +// ev := builder.NewEvent() +// ev.Add(data) +// ev.Send() // // Deprecated: SendNow is deprecated and may be removed in a future major release. func (b *Builder) SendNow(data interface{}) error { @@ -947,18 +947,23 @@ func (b *Builder) NewEvent() *Event { Timestamp: time.Now(), client: b.client, } - e.data = make(map[string]interface{}) - + // Set up locks b.lock.RLock() defer b.lock.RUnlock() + b.dynFieldsLock.RLock() + defer b.dynFieldsLock.RUnlock() + e.lock.Lock() + defer e.lock.Unlock() + + e.data = make(map[string]interface{}, len(b.data)+len(b.dynFields)) for k, v := range b.data { e.data[k] = v } - // create dynamic metrics - b.dynFieldsLock.RLock() - defer b.dynFieldsLock.RUnlock() + + // create dynamic metrics. for _, dynField := range b.dynFields { - e.AddField(dynField.name, dynField.fn()) + // Perform the data mutation while locked. + e.data[dynField.name] = dynField.fn() } return e } @@ -973,12 +978,14 @@ func (b *Builder) Clone() *Builder { APIHost: b.APIHost, client: b.client, } - newB.data = make(map[string]interface{}) + b.lock.RLock() defer b.lock.RUnlock() + newB.data = make(map[string]interface{}, len(b.data)) for k, v := range b.data { newB.data[k] = v } + // copy dynamic metric generators b.dynFieldsLock.RLock() defer b.dynFieldsLock.RUnlock() diff --git a/vendor/github.com/honeycombio/libhoney-go/transmission/transmission.go b/vendor/github.com/honeycombio/libhoney-go/transmission/transmission.go index 572b98b48..2ecc5972c 100644 --- a/vendor/github.com/honeycombio/libhoney-go/transmission/transmission.go +++ b/vendor/github.com/honeycombio/libhoney-go/transmission/transmission.go @@ -20,11 +20,13 @@ import ( "net/http" "net/url" "path" + "runtime" "strings" "sync" "time" "github.com/facebookgo/muster" + "github.com/honeycombio/libhoney-go/version" "github.com/klauspost/compress/zstd" "github.com/vmihailenco/msgpack/v5" ) @@ -39,8 +41,23 @@ const ( defaultSendTimeout = time.Second * 60 ) -// Version is the build version, set by libhoney -var Version string +var ( + // Libhoney's portion of the User-Agent header, e.g. "libhoney/1.2.3" + baseUserAgent = fmt.Sprintf("libhoney-go/%s", version.Version) + // Information about the runtime environment for inclusion in User-Agent + runtimeInfo = fmt.Sprintf("%s (%s/%s)", strings.Replace(runtime.Version(), "go", "go/", 1), runtime.GOOS, runtime.GOARCH) + // The default User-Agent when no additions have been given + defaultUserAgent = fmt.Sprintf("%s %s", baseUserAgent, runtimeInfo) +) + +// Return a user-agent value including any additions made in the configuration +func fmtUserAgent(addition string) string { + if addition != "" { + return fmt.Sprintf("%s %s %s", baseUserAgent, strings.TrimSpace(addition), runtimeInfo) + } else { + return defaultUserAgent + } +} type Honeycomb struct { // How many events to collect into a batch before sending. A @@ -407,12 +424,6 @@ func (b *batchAgg) fireBatch(events []*Event) { // build the HTTP request url.Path = path.Join(url.Path, "/1/batch", dataset) - // sigh. dislike - userAgent := fmt.Sprintf("libhoney-go/%s", Version) - if b.userAgentAddition != "" { - userAgent = fmt.Sprintf("%s %s", userAgent, strings.TrimSpace(b.userAgentAddition)) - } - // One retry allowed for connection timeouts. var resp *http.Response for try := 0; try < 2; try++ { @@ -435,7 +446,7 @@ func (b *batchAgg) fireBatch(events []*Event) { req.Header.Set("Content-Encoding", "zstd") } - req.Header.Set("User-Agent", userAgent) + req.Header.Set("User-Agent", fmtUserAgent(b.userAgentAddition)) req.Header.Add("X-Honeycomb-Team", writeKey) // send off batch! resp, err = b.httpClient.Do(req) @@ -541,7 +552,7 @@ func (b *batchAgg) fireBatch(events []*Event) { for _, resp := range batchResponses { resp.Duration = dur / time.Duration(numEncoded) for eIdx < len(events) && events[eIdx] == nil { - fmt.Printf("incr, eIdx: %d, len(evs): %d\n", eIdx, len(events)) + b.logger.Printf("incr, eIdx: %d, len(evs): %d", eIdx, len(events)) eIdx++ } if eIdx == len(events) { // just in case diff --git a/vendor/github.com/honeycombio/libhoney-go/version/version.go b/vendor/github.com/honeycombio/libhoney-go/version/version.go new file mode 100644 index 000000000..3a5489206 --- /dev/null +++ b/vendor/github.com/honeycombio/libhoney-go/version/version.go @@ -0,0 +1,5 @@ +package version + +const ( + Version string = "1.18.0" +) diff --git a/vendor/modules.txt b/vendor/modules.txt index 7495a4df6..2439249cb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -271,10 +271,11 @@ github.com/hinshun/vt10x # github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e ## explicit github.com/hokaccha/go-prettyjson -# github.com/honeycombio/libhoney-go v1.17.0 +# github.com/honeycombio/libhoney-go v1.18.0 ## explicit; go 1.14 github.com/honeycombio/libhoney-go github.com/honeycombio/libhoney-go/transmission +github.com/honeycombio/libhoney-go/version # github.com/imdario/mergo v0.3.13 ## explicit; go 1.13 github.com/imdario/mergo