plugin/metrics: Switch to using promhttp instead of deprecated Handler (#1312)

prometheus.Handler is deprecated according to the godoc for the package so
instead we're using promhttp.

Additionally, we are exposing the Registry that metrics is using so other
plugins that are not inside of coredns can read the registry. Otherwise, if
we kept using the Default one, there's no way to access that from outside
of the coredns repo since it is vendored.
This commit is contained in:
James Hartig 2017-12-14 13:19:03 -05:00 committed by Miek Gieben
parent 1919913c98
commit 671d170619
6728 changed files with 1994787 additions and 16 deletions

View file

@ -0,0 +1,117 @@
## Contribution Guidelines
### Pull requests are always welcome
We are always thrilled to receive pull requests, and do our best to
process them as fast as possible. Not sure if that typo is worth a pull
request? Do it! We will appreciate it.
If your pull request is not accepted on the first try, don't be
discouraged! If there's a problem with the implementation, hopefully you
received feedback on what to improve.
We're trying very hard to keep go-swagger lean and focused. We don't want it
to do everything for everybody. This means that we might decide against
incorporating a new feature. However, there might be a way to implement
that feature *on top of* go-swagger.
### Conventions
Fork the repo and make changes on your fork in a feature branch:
- If it's a bugfix branch, name it XXX-something where XXX is the number of the
issue
- If it's a feature branch, create an enhancement issue to announce your
intentions, and name it XXX-something where XXX is the number of the issue.
Submit unit tests for your changes. Go has a great test framework built in; use
it! Take a look at existing tests for inspiration. Run the full test suite on
your branch before submitting a pull request.
Update the documentation when creating or modifying features. Test
your documentation changes for clarity, concision, and correctness, as
well as a clean documentation build. See ``docs/README.md`` for more
information on building the docs and how docs get released.
Write clean code. Universally formatted code promotes ease of writing, reading,
and maintenance. Always run `gofmt -s -w file.go` on each changed file before
committing your changes. Most editors have plugins that do this automatically.
Pull requests descriptions should be as clear as possible and include a
reference to all the issues that they address.
Pull requests must not contain commits from other users or branches.
Commit messages must start with a capitalized and short summary (max. 50
chars) written in the imperative, followed by an optional, more detailed
explanatory text which is separated from the summary by an empty line.
Code review comments may be added to your pull request. Discuss, then make the
suggested modifications and push additional commits to your feature branch. Be
sure to post a comment after pushing. The new commits will show up in the pull
request automatically, but the reviewers will not be notified unless you
comment.
Before the pull request is merged, make sure that you squash your commits into
logical units of work using `git rebase -i` and `git push -f`. After every
commit the test suite should be passing. Include documentation changes in the
same commit so that a revert would remove all traces of the feature or fix.
Commits that fix or close an issue should include a reference like `Closes #XXX`
or `Fixes #XXX`, which will automatically close the issue when merged.
### Sign your work
The sign-off is a simple line at the end of the explanation for the
patch, which certifies that you wrote it or otherwise have the right to
pass it on as an open-source patch. The rules are pretty simple: if you
can certify the below (from
[developercertificate.org](http://developercertificate.org/)):
```
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
660 York Street, Suite 102,
San Francisco, CA 94110 USA
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
```
then you just add a line to every git commit message:
Signed-off-by: Joe Smith <joe@gmail.com>
using your real name (sorry, no pseudonyms or anonymous contributions.)
You can add the sign off when creating the git commit via `git commit -s`.

18
vendor/github.com/go-openapi/strfmt/conv/date.go generated vendored Normal file
View file

@ -0,0 +1,18 @@
package conv
import "github.com/go-openapi/strfmt"
// Date returns a pointer to of the Date value passed in.
func Date(v strfmt.Date) *strfmt.Date {
return &v
}
// DateValue returns the value of the Date pointer passed in or
// the default value if the pointer is nil.
func DateValue(v *strfmt.Date) strfmt.Date {
if v == nil {
return strfmt.Date{}
}
return *v
}

15
vendor/github.com/go-openapi/strfmt/conv/date_test.go generated vendored Normal file
View file

@ -0,0 +1,15 @@
package conv
import (
"testing"
"time"
"github.com/go-openapi/strfmt"
"github.com/stretchr/testify/assert"
)
func TestDateValue(t *testing.T) {
assert.Equal(t, strfmt.Date{}, DateValue(nil))
date := strfmt.Date(time.Now())
assert.Equal(t, date, DateValue(&date))
}

290
vendor/github.com/go-openapi/strfmt/conv/default.go generated vendored Normal file
View file

@ -0,0 +1,290 @@
package conv
import (
"github.com/go-openapi/strfmt"
)
// Base64 returns a pointer to of the Base64 value passed in.
func Base64(v strfmt.Base64) *strfmt.Base64 {
return &v
}
// Base64Value returns the value of the Base64 pointer passed in or
// the default value if the pointer is nil.
func Base64Value(v *strfmt.Base64) strfmt.Base64 {
if v == nil {
return nil
}
return *v
}
// URI returns a pointer to of the URI value passed in.
func URI(v strfmt.URI) *strfmt.URI {
return &v
}
// URIValue returns the value of the URI pointer passed in or
// the default value if the pointer is nil.
func URIValue(v *strfmt.URI) strfmt.URI {
if v == nil {
return strfmt.URI("")
}
return *v
}
// Email returns a pointer to of the Email value passed in.
func Email(v strfmt.Email) *strfmt.Email {
return &v
}
// EmailValue returns the value of the Email pointer passed in or
// the default value if the pointer is nil.
func EmailValue(v *strfmt.Email) strfmt.Email {
if v == nil {
return strfmt.Email("")
}
return *v
}
// Hostname returns a pointer to of the Hostname value passed in.
func Hostname(v strfmt.Hostname) *strfmt.Hostname {
return &v
}
// HostnameValue returns the value of the Hostname pointer passed in or
// the default value if the pointer is nil.
func HostnameValue(v *strfmt.Hostname) strfmt.Hostname {
if v == nil {
return strfmt.Hostname("")
}
return *v
}
// IPv4 returns a pointer to of the IPv4 value passed in.
func IPv4(v strfmt.IPv4) *strfmt.IPv4 {
return &v
}
// IPv4Value returns the value of the IPv4 pointer passed in or
// the default value if the pointer is nil.
func IPv4Value(v *strfmt.IPv4) strfmt.IPv4 {
if v == nil {
return strfmt.IPv4("")
}
return *v
}
// IPv6 returns a pointer to of the IPv6 value passed in.
func IPv6(v strfmt.IPv6) *strfmt.IPv6 {
return &v
}
// IPv6Value returns the value of the IPv6 pointer passed in or
// the default value if the pointer is nil.
func IPv6Value(v *strfmt.IPv6) strfmt.IPv6 {
if v == nil {
return strfmt.IPv6("")
}
return *v
}
// MAC returns a pointer to of the MAC value passed in.
func MAC(v strfmt.MAC) *strfmt.MAC {
return &v
}
// MACValue returns the value of the MAC pointer passed in or
// the default value if the pointer is nil.
func MACValue(v *strfmt.MAC) strfmt.MAC {
if v == nil {
return strfmt.MAC("")
}
return *v
}
// UUID returns a pointer to of the UUID value passed in.
func UUID(v strfmt.UUID) *strfmt.UUID {
return &v
}
// UUIDValue returns the value of the UUID pointer passed in or
// the default value if the pointer is nil.
func UUIDValue(v *strfmt.UUID) strfmt.UUID {
if v == nil {
return strfmt.UUID("")
}
return *v
}
// UUID3 returns a pointer to of the UUID3 value passed in.
func UUID3(v strfmt.UUID3) *strfmt.UUID3 {
return &v
}
// UUID3Value returns the value of the UUID3 pointer passed in or
// the default value if the pointer is nil.
func UUID3Value(v *strfmt.UUID3) strfmt.UUID3 {
if v == nil {
return strfmt.UUID3("")
}
return *v
}
// UUID4 returns a pointer to of the UUID4 value passed in.
func UUID4(v strfmt.UUID4) *strfmt.UUID4 {
return &v
}
// UUID4Value returns the value of the UUID4 pointer passed in or
// the default value if the pointer is nil.
func UUID4Value(v *strfmt.UUID4) strfmt.UUID4 {
if v == nil {
return strfmt.UUID4("")
}
return *v
}
// UUID5 returns a pointer to of the UUID5 value passed in.
func UUID5(v strfmt.UUID5) *strfmt.UUID5 {
return &v
}
// UUID5Value returns the value of the UUID5 pointer passed in or
// the default value if the pointer is nil.
func UUID5Value(v *strfmt.UUID5) strfmt.UUID5 {
if v == nil {
return strfmt.UUID5("")
}
return *v
}
// ISBN returns a pointer to of the ISBN value passed in.
func ISBN(v strfmt.ISBN) *strfmt.ISBN {
return &v
}
// ISBNValue returns the value of the ISBN pointer passed in or
// the default value if the pointer is nil.
func ISBNValue(v *strfmt.ISBN) strfmt.ISBN {
if v == nil {
return strfmt.ISBN("")
}
return *v
}
// ISBN10 returns a pointer to of the ISBN10 value passed in.
func ISBN10(v strfmt.ISBN10) *strfmt.ISBN10 {
return &v
}
// ISBN10Value returns the value of the ISBN10 pointer passed in or
// the default value if the pointer is nil.
func ISBN10Value(v *strfmt.ISBN10) strfmt.ISBN10 {
if v == nil {
return strfmt.ISBN10("")
}
return *v
}
// ISBN13 returns a pointer to of the ISBN13 value passed in.
func ISBN13(v strfmt.ISBN13) *strfmt.ISBN13 {
return &v
}
// ISBN13Value returns the value of the ISBN13 pointer passed in or
// the default value if the pointer is nil.
func ISBN13Value(v *strfmt.ISBN13) strfmt.ISBN13 {
if v == nil {
return strfmt.ISBN13("")
}
return *v
}
// CreditCard returns a pointer to of the CreditCard value passed in.
func CreditCard(v strfmt.CreditCard) *strfmt.CreditCard {
return &v
}
// CreditCardValue returns the value of the CreditCard pointer passed in or
// the default value if the pointer is nil.
func CreditCardValue(v *strfmt.CreditCard) strfmt.CreditCard {
if v == nil {
return strfmt.CreditCard("")
}
return *v
}
// SSN returns a pointer to of the SSN value passed in.
func SSN(v strfmt.SSN) *strfmt.SSN {
return &v
}
// SSNValue returns the value of the SSN pointer passed in or
// the default value if the pointer is nil.
func SSNValue(v *strfmt.SSN) strfmt.SSN {
if v == nil {
return strfmt.SSN("")
}
return *v
}
// HexColor returns a pointer to of the HexColor value passed in.
func HexColor(v strfmt.HexColor) *strfmt.HexColor {
return &v
}
// HexColorValue returns the value of the HexColor pointer passed in or
// the default value if the pointer is nil.
func HexColorValue(v *strfmt.HexColor) strfmt.HexColor {
if v == nil {
return strfmt.HexColor("")
}
return *v
}
// RGBColor returns a pointer to of the RGBColor value passed in.
func RGBColor(v strfmt.RGBColor) *strfmt.RGBColor {
return &v
}
// RGBColorValue returns the value of the RGBColor pointer passed in or
// the default value if the pointer is nil.
func RGBColorValue(v *strfmt.RGBColor) strfmt.RGBColor {
if v == nil {
return strfmt.RGBColor("")
}
return *v
}
// Password returns a pointer to of the Password value passed in.
func Password(v strfmt.Password) *strfmt.Password {
return &v
}
// PasswordValue returns the value of the Password pointer passed in or
// the default value if the pointer is nil.
func PasswordValue(v *strfmt.Password) strfmt.Password {
if v == nil {
return strfmt.Password("")
}
return *v
}

View file

@ -0,0 +1,122 @@
package conv
import (
"testing"
"github.com/go-openapi/strfmt"
"github.com/stretchr/testify/assert"
)
func TestBase64Value(t *testing.T) {
assert.Equal(t, strfmt.Base64(nil), Base64Value(nil))
base64 := strfmt.Base64([]byte{4, 2})
assert.Equal(t, base64, Base64Value(&base64))
}
func TestURIValue(t *testing.T) {
assert.Equal(t, strfmt.URI(""), URIValue(nil))
value := strfmt.URI("foo")
assert.Equal(t, value, URIValue(&value))
}
func TestEmailValue(t *testing.T) {
assert.Equal(t, strfmt.Email(""), EmailValue(nil))
value := strfmt.Email("foo")
assert.Equal(t, value, EmailValue(&value))
}
func TestHostnameValue(t *testing.T) {
assert.Equal(t, strfmt.Hostname(""), HostnameValue(nil))
value := strfmt.Hostname("foo")
assert.Equal(t, value, HostnameValue(&value))
}
func TestIPv4Value(t *testing.T) {
assert.Equal(t, strfmt.IPv4(""), IPv4Value(nil))
value := strfmt.IPv4("foo")
assert.Equal(t, value, IPv4Value(&value))
}
func TestIPv6Value(t *testing.T) {
assert.Equal(t, strfmt.IPv6(""), IPv6Value(nil))
value := strfmt.IPv6("foo")
assert.Equal(t, value, IPv6Value(&value))
}
func TestMACValue(t *testing.T) {
assert.Equal(t, strfmt.MAC(""), MACValue(nil))
value := strfmt.MAC("foo")
assert.Equal(t, value, MACValue(&value))
}
func TestUUIDValue(t *testing.T) {
assert.Equal(t, strfmt.UUID(""), UUIDValue(nil))
value := strfmt.UUID("foo")
assert.Equal(t, value, UUIDValue(&value))
}
func TestUUID3Value(t *testing.T) {
assert.Equal(t, strfmt.UUID3(""), UUID3Value(nil))
value := strfmt.UUID3("foo")
assert.Equal(t, value, UUID3Value(&value))
}
func TestUUID4Value(t *testing.T) {
assert.Equal(t, strfmt.UUID4(""), UUID4Value(nil))
value := strfmt.UUID4("foo")
assert.Equal(t, value, UUID4Value(&value))
}
func TestUUID5Value(t *testing.T) {
assert.Equal(t, strfmt.UUID5(""), UUID5Value(nil))
value := strfmt.UUID5("foo")
assert.Equal(t, value, UUID5Value(&value))
}
func TestISBNValue(t *testing.T) {
assert.Equal(t, strfmt.ISBN(""), ISBNValue(nil))
value := strfmt.ISBN("foo")
assert.Equal(t, value, ISBNValue(&value))
}
func TestISBN10Value(t *testing.T) {
assert.Equal(t, strfmt.ISBN10(""), ISBN10Value(nil))
value := strfmt.ISBN10("foo")
assert.Equal(t, value, ISBN10Value(&value))
}
func TestISBN13Value(t *testing.T) {
assert.Equal(t, strfmt.ISBN13(""), ISBN13Value(nil))
value := strfmt.ISBN13("foo")
assert.Equal(t, value, ISBN13Value(&value))
}
func TestCreditCardValue(t *testing.T) {
assert.Equal(t, strfmt.CreditCard(""), CreditCardValue(nil))
value := strfmt.CreditCard("foo")
assert.Equal(t, value, CreditCardValue(&value))
}
func TestSSNValue(t *testing.T) {
assert.Equal(t, strfmt.SSN(""), SSNValue(nil))
value := strfmt.SSN("foo")
assert.Equal(t, value, SSNValue(&value))
}
func TestHexColorValue(t *testing.T) {
assert.Equal(t, strfmt.HexColor(""), HexColorValue(nil))
value := strfmt.HexColor("foo")
assert.Equal(t, value, HexColorValue(&value))
}
func TestRGBColorValue(t *testing.T) {
assert.Equal(t, strfmt.RGBColor(""), RGBColorValue(nil))
value := strfmt.RGBColor("foo")
assert.Equal(t, value, RGBColorValue(&value))
}
func TestPasswordValue(t *testing.T) {
assert.Equal(t, strfmt.Password(""), PasswordValue(nil))
value := strfmt.Password("foo")
assert.Equal(t, value, PasswordValue(&value))
}

18
vendor/github.com/go-openapi/strfmt/conv/duration.go generated vendored Normal file
View file

@ -0,0 +1,18 @@
package conv
import "github.com/go-openapi/strfmt"
// Duration returns a pointer to of the Duration value passed in.
func Duration(v strfmt.Duration) *strfmt.Duration {
return &v
}
// DurationValue returns the value of the Duration pointer passed in or
// the default value if the pointer is nil.
func DurationValue(v *strfmt.Duration) strfmt.Duration {
if v == nil {
return strfmt.Duration(0)
}
return *v
}

View file

@ -0,0 +1,14 @@
package conv
import (
"testing"
"github.com/go-openapi/strfmt"
"github.com/stretchr/testify/assert"
)
func TestDurationValue(t *testing.T) {
assert.Equal(t, strfmt.Duration(0), DurationValue(nil))
duration := strfmt.Duration(42)
assert.Equal(t, duration, DurationValue(&duration))
}

18
vendor/github.com/go-openapi/strfmt/conv/time.go generated vendored Normal file
View file

@ -0,0 +1,18 @@
package conv
import "github.com/go-openapi/strfmt"
// DateTime returns a pointer to of the DateTime value passed in.
func DateTime(v strfmt.DateTime) *strfmt.DateTime {
return &v
}
// DateTimeValue returns the value of the DateTime pointer passed in or
// the default value if the pointer is nil.
func DateTimeValue(v *strfmt.DateTime) strfmt.DateTime {
if v == nil {
return strfmt.DateTime{}
}
return *v
}

15
vendor/github.com/go-openapi/strfmt/conv/time_test.go generated vendored Normal file
View file

@ -0,0 +1,15 @@
package conv
import (
"testing"
"time"
"github.com/go-openapi/strfmt"
"github.com/stretchr/testify/assert"
)
func TestDateTimeValue(t *testing.T) {
assert.Equal(t, strfmt.DateTime{}, DateTimeValue(nil))
time := strfmt.DateTime(time.Now())
assert.Equal(t, time, DateTimeValue(&time))
}

20
vendor/github.com/go-openapi/strfmt/hack/coverage generated vendored Normal file
View file

@ -0,0 +1,20 @@
#!/bin/bash
set -e -o pipefail
# Run test coverage on each subdirectories and merge the coverage profile.
echo "mode: ${GOCOVMODE-atomic}" > coverage.txt
# Standard go tooling behavior is to ignore dirs with leading underscores
# skip generator for race detection and coverage
for dir in $(go list ./...)
do
pth="$GOPATH/src/$dir"
go test -race -timeout 20m -covermode=${GOCOVMODE-atomic} -coverprofile=${pth}/profile.out $dir
if [ -f $pth/profile.out ]
then
cat $pth/profile.out | tail -n +2 >> coverage.txt
rm $pth/profile.out
fi
done
go tool cover -func coverage.txt