Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated dependencies. #143

Merged
merged 24 commits into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 5 additions & 1 deletion .promu.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
verbose: false
go:
version: 1.12.0
cgo: false
repository:
path: github.com/Stackdriver/stackdriver-prometheus-sidecar
build:
binaries:
- name: stackdriver-prometheus-sidecar
path: ./cmd/stackdriver-prometheus-sidecar
flags: -a -tags netgo
flags: -mod=vendor -a -tags netgo
ldflags: |
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}}
Expand Down
19 changes: 17 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
language: go
script: make goveralls

go:
- 1.12.x

go_import_path: github.com/Stackdriver/stackdriver-prometheus-sidecar

# Skip dependency fetch. We store all dependencies under vendor/.
install: true

# make goveralls runs all tests as well.
script:
- make goveralls
# TODO(jkohen): `make goveralls` is causing a diff in go.mod. Prevent that and uncomment the line below.
#- git diff --exit-code

# Contains tokens for Coveralls. See https://docs.coveralls.io/go
env:
global:
secure: sNu7aGQUNSMBDfwCjVQCOxNlpwD4tfQBP5owdYMQLs/vrLEEeKOIH/g8R2QdI2H9AVIFofpbEC6bR9VXP5eo1hTmwF3MgGS1e7zD61+wdE4fqDAau0AR3fP344yg/m0YjQVIj8fhPByd+6Sjgzlt9K8A4eQr7e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zH9Q6ljETyzNR9oIJCHXoDF59pTcsO7vXutnUTOO8INuGBcKijfj3mYnT5FDJm1kOtQM1RBSx9c5W6CbKWD7i5wVCcfH9BAO4ncmT2C+NmEXRotQvB//VgGL5TB6ZeMIYjWSnDbhpNOFsRwsc0UbIT3yOON26YAY=
71 changes: 50 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,34 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Ensure GOBIN is not set during build so that promu is installed to the correct path
unexport GOBIN

GO ?= go
GOFMT ?= $(GO)fmt
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
GOHOSTOS ?= $(shell $(GO) env GOHOSTOS)
GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH)

# Enforce Go modules support just in case the directory is inside GOPATH (and for Travis CI).
export GO111MODULE=on
jkohen marked this conversation as resolved.
Show resolved Hide resolved
# Always use the local vendor/ directory to satisfy the dependencies.
GOOPTS := $(GOOPTS) -mod=vendor

PROMU := $(FIRST_GOPATH)/bin/promu
STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck
GOVERALLS := $(FIRST_GOPATH)/bin/goveralls
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
pkgs = ./...

ifeq (arm, $(GOHOSTARCH))
GOHOSTARM ?= $(shell GOARM= $(GO) env GOARM)
GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)v$(GOHOSTARM)
else
GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)
endif

PROMU_VERSION ?= 0.5.0
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz

PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
Expand All @@ -40,41 +61,48 @@ check_license:
@echo ">> checking license header"
@./scripts/check_license.sh

# TODO(fabxc): example tests temporarily removed.
deps:
@echo ">> getting dependencies"
ifdef GO111MODULE
GO111MODULE=$(GO111MODULE) $(GO) mod download
else
$(GO) get $(GOOPTS) -t ./...
endif

test-short:
@echo ">> running short tests"
@$(GO) test -short $(shell $(GO) list ./... | grep -v /vendor/ | grep -v examples)
$(GO) test -short $(GOOPTS) $(pkgs)

test:
@echo ">> running all tests"
@$(GO) test $(shell $(GO) list ./... | grep -v /vendor/ | grep -v examples)
$(GO) test $(GOOPTS) $(pkgs)

cover:
@echo ">> running all tests with coverage"
@$(GO) test -coverprofile=coverage.out $(shell $(GO) list ./... | grep -v /vendor/ | grep -v examples)
$(GO) test -v -coverprofile=coverage.out $(GOOPTS) $(pkgs)

format:
@echo ">> formatting code"
@$(GO) fmt $(pkgs)
$(GO) fmt $(pkgs)

vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)
$(GO) vet $(GOOPTS) $(pkgs)

staticcheck: $(STATICCHECK)
@echo ">> running staticcheck"
@$(STATICCHECK) $(pkgs)
$(STATICCHECK) $(pkgs)

goveralls: cover $(GOVERALLS)
ifndef COVERALLS_TOKEN
$(error COVERALLS_TOKEN is undefined, follow https://docs.coveralls.io/go to create one and go to https://coveralls.io to retrieve existing ones)
endif
@echo ">> running goveralls"
@$(GOVERALLS) -coverprofile=coverage.out -service=travis-ci -repotoken "${COVERALLS_TOKEN}"
$(GOVERALLS) -coverprofile=coverage.out -service=travis-ci -repotoken "${COVERALLS_TOKEN}"

build: promu
@echo ">> building binaries"
@$(PROMU) build --prefix $(PREFIX)
$(PROMU) build --prefix $(PREFIX)

build-linux-amd64: promu
@echo ">> building linux amd64 binaries"
Expand All @@ -86,29 +114,30 @@ tarball: promu

docker: build-linux-amd64
@echo ">> building docker image"
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .

push: test docker
@echo ">> pushing docker image"
docker push "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)"

assets:
@echo ">> writing assets"
@$(GO) get -u github.com/jteeuwen/go-bindata/...
@go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/...
@$(GO) fmt ./web/ui
$(GO) get -u github.com/jteeuwen/go-bindata/...
go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/...
$(GO) fmt ./web/ui

promu:
@echo ">> fetching promu"
@GOOS=$(shell uname -s | tr A-Z a-z) \
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
GO="$(GO)" \
$(GO) get -u github.com/prometheus/promu
$(eval PROMU_TMP := $(shell mktemp -d))
curl -s -L $(PROMU_URL) | tar -xvzf - -C $(PROMU_TMP)
mkdir -p $(FIRST_GOPATH)/bin
cp $(PROMU_TMP)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(FIRST_GOPATH)/bin/promu
rm -r $(PROMU_TMP)

$(FIRST_GOPATH)/bin/staticcheck:
@GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck

$(FIRST_GOPATH)/bin/goveralls:
@GOOS= GOARCH= $(GO) get -u github.com/mattn/goveralls
GOOS= GOARCH= $(GO) get -u github.com/mattn/goveralls

.PHONY: all style check_license format build test vet assets tarball docker promu staticcheck $(FIRST_GOPATH)/bin/staticcheck goveralls $(FIRST_GOPATH)/bin/goveralls
.PHONY: all style check_license deps format build test vet assets tarball docker promu staticcheck $(FIRST_GOPATH)/bin/staticcheck goveralls $(FIRST_GOPATH)/bin/goveralls
21 changes: 11 additions & 10 deletions cmd/stackdriver-prometheus-sidecar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"time"

md "cloud.google.com/go/compute/metadata"
oc_prometheus "contrib.go.opencensus.io/exporter/prometheus"
oc_stackdriver "contrib.go.opencensus.io/exporter/stackdriver"
"github.com/Stackdriver/stackdriver-prometheus-sidecar/metadata"
"github.com/Stackdriver/stackdriver-prometheus-sidecar/retrieval"
Expand All @@ -53,7 +54,6 @@ import (
"github.com/prometheus/prometheus/pkg/textparse"
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/scrape"
oc_prometheus "go.opencensus.io/exporter/prometheus"
"go.opencensus.io/plugin/ocgrpc"
"go.opencensus.io/plugin/ochttp"
"go.opencensus.io/stats/view"
Expand Down Expand Up @@ -196,8 +196,7 @@ type mainConfig struct {
UseRestrictedIPs bool
manualResolver *manual.Resolver
MonitoringBackends []string

LogLevel promlog.AllowedLevel
PromlogConfig promlog.Config
}

func main() {
Expand Down Expand Up @@ -269,7 +268,7 @@ func main() {
a.Flag("filter", "PromQL-style matcher for a single label which must pass for a series to be forwarded to Stackdriver. If repeated, the series must pass all filters to be forwarded. Deprecated, please use --include instead.").
StringsVar(&cfg.Filters)

promlogflag.AddFlags(a, &cfg.LogLevel)
promlogflag.AddFlags(a, &cfg.PromlogConfig)

_, err := a.Parse(os.Args[1:])
if err != nil {
Expand All @@ -278,7 +277,7 @@ func main() {
os.Exit(2)
}

logger := promlog.New(cfg.LogLevel)
logger := promlog.New(&cfg.PromlogConfig)
if cfg.ConfigFilename != "" {
cfg.MetricRenames, cfg.StaticMetadata, cfg.Aggregations, err = parseConfigFile(cfg.ConfigFilename)
if err != nil {
Expand Down Expand Up @@ -365,11 +364,13 @@ func main() {
// to resolve GCP API calls to the resolver.
cfg.manualResolver, _ = manual.GenerateAndRegisterManualResolver()
// These IP addresses correspond to restricted.googleapis.com and are not expected to change.
cfg.manualResolver.InitialAddrs([]resolver.Address{
{Addr: "199.36.153.4:443"},
{Addr: "199.36.153.5:443"},
{Addr: "199.36.153.6:443"},
{Addr: "199.36.153.7:443"},
cfg.manualResolver.InitialState(resolver.State{
Addresses: []resolver.Address{
{Addr: "199.36.153.4:443"},
{Addr: "199.36.153.5:443"},
{Addr: "199.36.153.6:443"},
{Addr: "199.36.153.7:443"},
},
})
}
targetsURL, err := cfg.PrometheusURL.Parse(targets.DefaultAPIEndpoint)
Expand Down
2 changes: 1 addition & 1 deletion cmd/stackdriver-prometheus-sidecar/statusz-tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h1>Parsed configuration</h1>
<tr><th>Kubernetes labels: cluster name</th><td>{{.KubernetesLabels.ClusterName}}</td></tr>
<tr><th>Kubernetes labels: location</th><td>{{.KubernetesLabels.Location}}</td></tr>
<tr><th>Listen address</th><td>{{.ListenAddress}}</td></tr>
<tr><th>Log level</th><td>{{.LogLevel.String}}</td></tr>
<tr><th>Log config</th><td>{{.PromlogConfig}}</td></tr>
jkohen marked this conversation as resolved.
Show resolved Hide resolved
<tr><th>Metrics prefix</th><td>{{.MetricsPrefix}}</td></tr>
<tr><th>Monitoring backends</th><td>{{.MonitoringBackends}}</td></tr>
<tr><th>Project ID resource</th><td>{{.ProjectIDResource}}</td></tr>
Expand Down
8 changes: 4 additions & 4 deletions cmd/stackdriver-prometheus-sidecar/statusz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func TestStatuszHandler(t *testing.T) {

matcher, _ := labels.NewMatcher(labels.MatchEqual, "k", "v")

var logLevel promlog.AllowedLevel
logLevel.Set("debug")
logConfig := promlog.Config{Level: &promlog.AllowedLevel{}}
logConfig.Level.Set("debug")

handler := &statuszHandler{
logger: log.NewLogfmtLogger(os.Stdout),
Expand All @@ -81,7 +81,7 @@ func TestStatuszHandler(t *testing.T) {
ClusterName: "my-cluster",
},
ListenAddress: "0.0.0.0:9091",
LogLevel: logLevel,
PromlogConfig: logConfig,
MetricRenames: map[string]string{"from1": "to1", "from2": "to2"},
MetricsPrefix: "external.googleapis.com/prometheus",
MonitoringBackends: []string{"prometheus", "stackdriver"},
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestStatuszHandler(t *testing.T) {
regexp.MustCompile(`<tr><th>Kubernetes labels: cluster name</th><td>my-cluster</td></tr>`),
regexp.MustCompile(`<tr><th>Kubernetes labels: location</th><td>us-central1-a</td></tr>`),
regexp.MustCompile(`<tr><th>Listen address</th><td>0.0.0.0:9091</td></tr>`),
regexp.MustCompile(`<tr><th>Log level</th><td>debug</td></tr>`),
regexp.MustCompile(`<tr><th>Log config</th><td>{debug &lt;nil&gt;}</td></tr>`),
regexp.MustCompile(`<tr><th>Metrics prefix</th><td>external.googleapis.com/prometheus</td></tr>`),
regexp.MustCompile(`<tr><th>Monitoring backends</th><td>\[prometheus stackdriver\]</td></tr>`),
regexp.MustCompile(`<tr><th>Project ID resource</th><td>my-project</td></tr>`),
Expand Down
63 changes: 63 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module github.com/Stackdriver/stackdriver-prometheus-sidecar

require (
cloud.google.com/go v0.43.0
contrib.go.opencensus.io/exporter/ocagent v0.6.0 // indirect
contrib.go.opencensus.io/exporter/prometheus v0.1.0
contrib.go.opencensus.io/exporter/stackdriver v0.12.4
github.com/Azure/azure-sdk-for-go v32.1.0+incompatible // indirect
github.com/Azure/go-autorest v12.4.1+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.5.0 // indirect
github.com/Azure/go-autorest/autorest/to v0.2.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.1.0 // indirect
github.com/Azure/go-autorest/tracing v0.2.0 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 // indirect
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 // indirect
github.com/aws/aws-sdk-go v1.21.10 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/ghodss/yaml v1.0.0
github.com/go-kit/kit v0.9.0
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48 // indirect
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
github.com/golang/protobuf v1.3.2
github.com/googleapis/gnostic v0.3.0 // indirect
github.com/gophercloud/gophercloud v0.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/grpc-ecosystem/grpc-gateway v1.9.5 // indirect
github.com/hashicorp/go-immutable-radix v1.1.0 // indirect
github.com/hashicorp/go-msgpack v0.5.5 // indirect
github.com/hashicorp/go-rootcerts v1.0.1 // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/hashicorp/memberlist v0.1.4 // indirect
github.com/hashicorp/serf v0.8.3 // indirect
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7 // indirect
github.com/json-iterator/go v1.1.7 // indirect
github.com/miekg/dns v1.1.15 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
github.com/oklog/oklog v0.3.2
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/opentracing/opentracing-go v1.1.0 // indirect
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v1.0.0
github.com/prometheus/common v0.4.1
github.com/prometheus/procfs v0.0.3 // indirect
github.com/prometheus/prometheus v0.0.0-20190710134608-e5b22494857d
jkohen marked this conversation as resolved.
Show resolved Hide resolved
github.com/prometheus/tsdb v0.10.0
github.com/samuel/go-zookeeper v0.0.0-20190801204459-3c104360edc8 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
go.opencensus.io v0.22.0
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 // indirect
golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64
google.golang.org/grpc v1.22.1
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
k8s.io/klog v0.3.3 // indirect
k8s.io/kube-openapi v0.0.0-20190722073852-5e22f3d471e6 // indirect
k8s.io/utils v0.0.0-20190801114015-581e00157fb1 // indirect
)
Loading