From 331db70d50ec2d5406ce6b21e9d15244db5c1cd9 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sun, 21 May 2017 10:04:35 +0200 Subject: [PATCH 1/3] ek package updated to v9 + added templates for github --- .github/CONTRIBUTING.md | 21 +++++++++++++ .github/ISSUE_TEMPLATE.md | 54 ++++++++++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 24 ++++++++++++++ .travis.yml | 2 +- Makefile | 8 ++--- changelog.md | 37 ++++++++++++++-------- examples/annotations_example.go | 2 +- examples/async_example.go | 12 ++++--- examples/basic_example.go | 16 ++++++---- examples/collector_example.go | 16 ++++++---- librato.go | 6 ++-- 11 files changed, 158 insertions(+), 40 deletions(-) create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..2a651a3 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,21 @@ +# Contributing Guidelines + +Contributing guidelines for open-source EK projects. + +**IMPORTANT! Contribute your code only if you have an excellent understanding of project idea and all existing code base. Otherwise, a nicely formatted issue will be more helpful to us.** + +### Issues + +1. Provide product version where the problem was found; +2. Provide info about your environment; +3. Provide detailed info about your problem; +4. Provide steps to reproduce the problem; +5. Provide actual and expected results. + +### Code + +1. Check your code **before** creating pull request; +2. If tests are present in a project, add tests for your code; +3. Add inline documentation for your code; +4. Apply code style used throughout the project; +5. Create your pull request to `develop` branch (_pull requests to other branches are not allowed_). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2fdfa8e --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,54 @@ +_Before opening an issue, search for similar bug reports or feature requests on GitHub Issues. If yes, please add a_ 👍 _reaction to the existing issue. If no similar issue can be found, fill out either the "Bug Report" or the "Feature Request" section below. Erase the other section and everything on and above this line._ + +### Bug report + +**System info:** + +* **Version used (`grep 'VERSION' librato.go`):** +* **OS (`cat /etc/*-release`):** +* **Kernel (`uname -a`):** +* **Go version (`go version`):** +* **Install tools:** + +**System info:** + +1. [First Step] +2. [Second Step] +3. [and so on...] + +**Expected behavior:** + +[What you expected to happen] + +**Actual behavior:** + +[What actually happened] + +**Additional info:** + +[Include gist of relevant config, logs, etc.] + +Please run those if possible and link them from a [gist](http://gist.github.com). + +--- + +### Feature Request + +Opening a feature request kicks off a discussion. Requests may be closed if we're not actively planning to work on them. + +**Proposal:** + +[Description of the feature] + +**Current behavior:** + +[What currently happens] + +**Desired behavior:** + +[What you would like to happen] + +**Use case:** + +[Why is this important (helps with prioritizing requests)] + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..e7814b8 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,24 @@ +### What did you implement: + +Closes #XXXXX + +### How did you implement it: + +... + +### How can we verify it: + +... + +### TODO's: + +- [ ] Write tests +- [ ] Write documentation +- [ ] Check that there aren't other open pull requests for the same issue/feature +- [ ] Format your source code by `make fmt` +- [ ] Provide verification config / commands +- [ ] Enable "Allow edits from maintainers" for this PR +- [ ] Update the messages below + +**Is this ready for review?:** No +**Is it a breaking change?:** No diff --git a/.travis.yml b/.travis.yml index 5873158..54b8ff2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ matrix: before_install: - make deps - mkdir -p $GOPATH/src/pkg.re/essentialkaos - - ln -sf $GOPATH/src/github.com/essentialkaos/librato $GOPATH/src/pkg.re/essentialkaos/librato.v6 + - ln -sf $GOPATH/src/github.com/essentialkaos/librato $GOPATH/src/pkg.re/essentialkaos/librato.v7 script: - go build examples/annotations_example.go diff --git a/Makefile b/Makefile index 5ae027b..ba0f01f 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,14 @@ ######################################################################################## -# This Makefile generated by GoMakeGen 0.5.0 using next command: +# This Makefile generated by GoMakeGen 0.6.0 using next command: # gomakegen --metalinter . ######################################################################################## -.PHONY = fmt deps metalinter +.PHONY = fmt metalinter ######################################################################################## -deps: - git config --global http.https://pkg.re.followRedirects true - go get -d -v pkg.re/essentialkaos/ek.v8 - fmt: find . -name "*.go" -exec gofmt -s -w {} \; diff --git a/changelog.md b/changelog.md index 72301f8..b51288a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,47 +1,58 @@ ## Changelog -#### v5.0.0 +### 7.0.0 + +--- + +### 6.0.0 + +* `ek` package updated to v8 +* Improved Makefile + +--- + +#### 5.0.0 * `ek` package updated to v7 --- -#### v4.1.0 +#### 4.1.0 * `ek` package updated to v6 -#### v4.0.0 +#### 4.0.0 * Custom [ek](https://github.com/essentialkaos/ek) `req.Engine` support --- -#### v3.0.0 +#### 3.0.0 * Each `Metrics` and `Collector` instance now have it's own `req.Engine` for sending requests * EK package updated to v5 --- -#### v2.0.5 +#### 2.0.5 * Fixed error handling * Improved error handling * Code refactoring -#### v2.0.4 +#### 2.0.4 * Improved error handling -#### v2.0.3 +#### 2.0.3 * Global prefix feature removed -#### v2.0.1 +#### 2.0.1 * EK package updated to latest version -#### v2.0.0 +#### 2.0.0 * Added usage examples * Using values instead pointers for measurements (gauge/counter) structs @@ -50,20 +61,20 @@ --- -#### v1.2.1 +#### 1.2.1 * Added pkg.re usage -#### v1.2 +#### 1.2.0 * Improved async data sending * Fixed minor bug with getting EOF error -#### v1.1 +#### 1.1.0 * Added `Collector` for collecting metrics for some period * Some minor improvements -#### v1 +#### 1.0.0 Initial public release diff --git a/examples/annotations_example.go b/examples/annotations_example.go index 82b02f8..733c79d 100644 --- a/examples/annotations_example.go +++ b/examples/annotations_example.go @@ -6,7 +6,7 @@ import ( "fmt" "time" - "pkg.re/essentialkaos/librato.v6" + "pkg.re/essentialkaos/librato.v7" ) // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/examples/async_example.go b/examples/async_example.go index 9e19071..3c8ade7 100644 --- a/examples/async_example.go +++ b/examples/async_example.go @@ -4,11 +4,10 @@ package main import ( "fmt" + "math/rand" "time" - "pkg.re/essentialkaos/ek.v8/rand" - - "pkg.re/essentialkaos/librato.v6" + "pkg.re/essentialkaos/librato.v7" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -31,10 +30,15 @@ func main() { metrics.Add( librato.Gauge{ Name: "example:gauge_1", - Value: rand.Int(1000), + Value: randomInt(1000), }, ) time.Sleep(15 * time.Second) } } + +func randomInt(n int) int { + rand.Seed(time.Now().UTC().UnixNano()) + return rand.Intn(n) +} diff --git a/examples/basic_example.go b/examples/basic_example.go index ae3fa0f..1dc6713 100644 --- a/examples/basic_example.go +++ b/examples/basic_example.go @@ -4,11 +4,10 @@ package main import ( "fmt" + "math/rand" "time" - "pkg.re/essentialkaos/ek.v8/rand" - - "pkg.re/essentialkaos/librato.v6" + "pkg.re/essentialkaos/librato.v7" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -21,16 +20,16 @@ func main() { errs := librato.AddMetric( librato.Gauge{ Name: "example:gauge_1", - Value: rand.Int(1000), + Value: randomInt(1000), }, librato.Gauge{ Name: "example:gauge_2", - Value: float64(rand.Int(1000)) / 5.0, + Value: float64(randomInt(1000)) / 5.0, Source: "go_librato_example", }, librato.Counter{ Name: "example:counter_1", - Value: rand.Int(1000), + Value: randomInt(1000), }, ) @@ -47,3 +46,8 @@ func main() { time.Sleep(time.Minute) } } + +func randomInt(n int) int { + rand.Seed(time.Now().UTC().UnixNano()) + return rand.Intn(n) +} diff --git a/examples/collector_example.go b/examples/collector_example.go index 91cd265..cf90b9a 100644 --- a/examples/collector_example.go +++ b/examples/collector_example.go @@ -4,11 +4,10 @@ package main import ( "fmt" + "math/rand" "time" - "pkg.re/essentialkaos/ek.v8/rand" - - "pkg.re/essentialkaos/librato.v6" + "pkg.re/essentialkaos/librato.v7" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -31,16 +30,16 @@ func collectSomeMetrics() []librato.Measurement { return []librato.Measurement{ librato.Gauge{ Name: "example:gauge_1", - Value: rand.Int(1000), + Value: randomInt(1000), }, librato.Gauge{ Name: "example:gauge_2", - Value: float64(rand.Int(1000)) / float64(rand.Int(20)), + Value: float64(randomInt(1000)) / float64(randomInt(20)), Source: "go_librato_example", }, librato.Counter{ Name: "example:counter_1", - Value: rand.Int(1000), + Value: randomInt(1000), }, } } @@ -52,3 +51,8 @@ func errorHandler(errs []error) { fmt.Printf(" %v\n", err) } } + +func randomInt(n int) int { + rand.Seed(time.Now().UTC().UnixNano()) + return rand.Intn(n) +} diff --git a/librato.go b/librato.go index 571e8b8..8c35cc4 100644 --- a/librato.go +++ b/librato.go @@ -15,14 +15,14 @@ import ( "strings" "time" - "pkg.re/essentialkaos/ek.v8/req" - "pkg.re/essentialkaos/ek.v8/timeutil" + "pkg.re/essentialkaos/ek.v9/req" + "pkg.re/essentialkaos/ek.v9/timeutil" ) // ////////////////////////////////////////////////////////////////////////////////// // // VERSION contains current version of librato package and used as part of User-Agent -const VERSION = "6.0.0" +const VERSION = "7.0.0" // ////////////////////////////////////////////////////////////////////////////////// // From eae328b1ffacf728d7c0acc593f6704a69798f00 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sun, 21 May 2017 10:08:05 +0200 Subject: [PATCH 2/3] Improved readme and makefile --- Makefile | 6 +++++- changelog.md | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ba0f01f..791acdb 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,14 @@ ######################################################################################## -.PHONY = fmt metalinter +.PHONY = fmt deps metalinter ######################################################################################## +deps: + git config --global http.https://pkg.re.followRedirects true + go get -d -v pkg.re/essentialkaos/ek.v9 + fmt: find . -name "*.go" -exec gofmt -s -w {} \; diff --git a/changelog.md b/changelog.md index b51288a..69adf11 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,8 @@ ### 7.0.0 +* `ek` package updated to v9 + --- ### 6.0.0 From ea7b86f587b9ef298f2fb2904d4f60e0fac1180e Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Fri, 26 May 2017 13:05:12 +0200 Subject: [PATCH 3/3] Improved readme --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index a10f7f2..8fd9501 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# Librato [![GoDoc](https://godoc.org/pkg.re/essentialkaos/librato.v6?status.svg)](https://godoc.org/pkg.re/essentialkaos/librato.v6) [![Build Status](https://travis-ci.org/essentialkaos/librato.svg?branch=master)](https://travis-ci.org/essentialkaos/librato) [![Go Report Card](https://goreportcard.com/badge/github.com/essentialkaos/librato)](https://goreportcard.com/report/github.com/essentialkaos/librato) [![codebeat badge](https://codebeat.co/badges/f82e704d-67a7-4c6f-9e5d-1acf058c937b)](https://codebeat.co/projects/github-com-essentialkaos-librato) [![License](https://gh.kaos.io/ekol.svg)](https://essentialkaos.com/ekol) +# Librato [![GoDoc](https://godoc.org/pkg.re/essentialkaos/librato.v7?status.svg)](https://godoc.org/pkg.re/essentialkaos/librato.v7) [![Build Status](https://travis-ci.org/essentialkaos/librato.svg?branch=master)](https://travis-ci.org/essentialkaos/librato) [![Go Report Card](https://goreportcard.com/badge/github.com/essentialkaos/librato)](https://goreportcard.com/report/github.com/essentialkaos/librato) [![codebeat badge](https://codebeat.co/badges/f82e704d-67a7-4c6f-9e5d-1acf058c937b)](https://codebeat.co/projects/github-com-essentialkaos-librato) [![License](https://gh.kaos.io/ekol.svg)](https://essentialkaos.com/ekol) Package for working with [Librato Metrics](https://www.librato.com) API from Go code. @@ -13,13 +13,13 @@ git config --global http.https://pkg.re.followRedirects true Make sure you have a working Go 1.6+ workspace ([instructions](https://golang.org/doc/install)), then ``` -go get pkg.re/essentialkaos/librato.v6 +go get pkg.re/essentialkaos/librato.v7 ``` For update to latest stable release, do: ``` -go get -u pkg.re/essentialkaos/librato.v6 +go get -u pkg.re/essentialkaos/librato.v7 ``` ## Examples