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

Upgrade to using hashicorp/go-metrics instead of armon/go-metrics #679

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ jobs:
strategy:
matrix:
include:
- {goos: "linux", goarch: "arm"}
- {goos: "linux", goarch: "arm64"}
- {goos: "linux", goarch: "386"}
- {goos: "linux", goarch: "amd64"}
- {goos: "linux", goarch: "amd64", gotags: "fips", env: "CGO_ENABLED=1 GOEXPERIMENT=boringcrypto", fips: "+fips1402", pkg_suffix: "-fips" }
- {goos: "linux", goarch: "arm64", gotags: "fips", env: "CGO_ENABLED=1 GOEXPERIMENT=boringcrypto CC=aarch64-linux-gnu-gcc", fips: "+fips1402", pkg_suffix: "-fips" }
- {goos: "darwin", goarch: "amd64"}
- {goos: "darwin", goarch: "arm64"}
- {goos: "linux", goarch: "arm", gotags: "hashicorpmetrics"}
- {goos: "linux", goarch: "arm64", gotags: "hashicorpmetrics"}
- {goos: "linux", goarch: "386", gotags: "hashicorpmetrics"}
- {goos: "linux", goarch: "amd64", gotags: "hashicorpmetrics"}
- {goos: "linux", goarch: "amd64", gotags: "hashicorpmetrics,fips", env: "CGO_ENABLED=1 GOEXPERIMENT=boringcrypto", fips: "+fips1402", pkg_suffix: "-fips" }
- {goos: "linux", goarch: "arm64", gotags: "hashicorpmetrics,fips", env: "CGO_ENABLED=1 GOEXPERIMENT=boringcrypto CC=aarch64-linux-gnu-gcc", fips: "+fips1402", pkg_suffix: "-fips" }
- {goos: "darwin", goarch: "amd64", gotags: "hashicorpmetrics"}
- {goos: "darwin", goarch: "arm64", gotags: "hashicorpmetrics"}

fail-fast: true

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/consul-dataplane-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ on:
- main
- release/**
pull_request:


env:
GOFLAGS: "-tags=hashicorpmetrics"

jobs:
conditional-skip:
uses: ./.github/workflows/reusable-conditional-skip.yml
Expand Down
21 changes: 18 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

linters:
enable:
- depguard

issues:
exclude-rules:
# Allow usage of deprecated values.
- linters: [ staticcheck ]
text: 'SA1019:'
path: "(pkg/consuldp/bootstrap.go)"
- linters: [staticcheck]
text: "SA1019:"
path: "(pkg/consuldp/bootstrap.go)"

linters-settings:
depguard:
rules:
main:
list-mode: lax
deny:
- pkg: github.com/armon/go-metrics
desc: "use github.com/hashicorp/go-metrics"
- pkg: github.com/hashicorp/go-metrics/compat
desc: "use github.com/hashicorp/go-metrics"
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ PLATFORM = $(OS)/$(ARCH)
DIST = dist/$(PLATFORM)
BIN = $(DIST)/$(BIN_NAME)

GOTAGS=hashicorpmetrics

VERSION = $(shell ./build-scripts/version.sh pkg/version/version.go)
GOLANG_VERSION ?= $(shell head -n 1 .go-version)
BOOTSTRAP_PACKAGE_DIR=internal/bootstrap
Expand Down Expand Up @@ -44,7 +46,7 @@ dist: ## make dist directory and ignore everything

.PHONY: bin
bin: dist ## Build the binary
GOARCH=$(ARCH) GOOS=$(OS) CGO_ENABLED=0 go build -trimpath -buildvcs=false -ldflags="$(GOLDFLAGS)" -o $(BIN) ./cmd/$(BIN_NAME)
GOARCH=$(ARCH) GOOS=$(OS) CGO_ENABLED=0 go build -tags="$(GOTAGS)" -trimpath -buildvcs=false -ldflags="$(GOLDFLAGS)" -o $(BIN) ./cmd/$(BIN_NAME)

.PHONY: dev
dev: bin ## Build binary and copy to the destination
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ go 1.20

require (
dario.cat/mergo v1.0.0
github.com/armon/go-metrics v0.4.1
github.com/hashi-derek/grpc-proxy v0.0.0-20231207191910-191266484d75
github.com/hashicorp/consul-server-connection-manager v0.1.9
github.com/hashicorp/consul-server-connection-manager v0.1.10
github.com/hashicorp/consul/proto-public v0.6.3
github.com/hashicorp/go-hclog v1.5.0
github.com/hashicorp/go-metrics v0.5.4
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-rootcerts v1.0.2
github.com/mitchellh/mapstructure v1.5.0
Expand All @@ -20,6 +20,7 @@ require (

require (
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ github.com/hashi-derek/grpc-proxy v0.0.0-20231207191910-191266484d75 h1:V5Uqf7Vo
github.com/hashi-derek/grpc-proxy v0.0.0-20231207191910-191266484d75/go.mod h1:5eEnHfK72jOkp4gC1dI/Q/E9MFNOM/ewE/vql5ijV3g=
github.com/hashicorp/consul-server-connection-manager v0.1.9 h1:jHO10v0Hk/WE05qz1gnUDd9WPQEFf5e2bP1Gs+s56rA=
github.com/hashicorp/consul-server-connection-manager v0.1.9/go.mod h1:rsVRioiTxfyh4yXcEnm1Lb9RrzJl0Lz08+nLgdlZR2I=
github.com/hashicorp/consul-server-connection-manager v0.1.10 h1:L4O8Y+vSoF2e+Yj8ttuYiuDCglCseXt9hB09AXeXHAM=
github.com/hashicorp/consul-server-connection-manager v0.1.10/go.mod h1:Y2BihRUCMQtooOQTyrlMzfa04OjXfu/zcsX34tBCcjY=
github.com/hashicorp/consul/proto-public v0.6.3 h1:iDA+fHtcqIc3kMMWkND6CD9W98jfKER0EC9GI7jOUvg=
github.com/hashicorp/consul/proto-public v0.6.3/go.mod h1:a1pOtKbQ2+iRnMlEA2bywlEZ0nbCQ2pS7GDQN6pqLwU=
github.com/hashicorp/consul/sdk v0.16.1 h1:V8TxTnImoPD5cj0U9Spl0TUxcytjcbbJeADFF07KdHg=
Expand All @@ -160,6 +162,8 @@ github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+
github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-metrics v0.5.4 h1:8mmPiIJkTPPEbAiV97IxdAGNdRdaWwVap1BU6elejKY=
github.com/hashicorp/go-metrics v0.5.4/go.mod h1:CG5yz4NZ/AI/aQt9Ucm/vdBnbh7fvmv4lxZ350i+QQI=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-netaddrs v0.1.0 h1:TnlYvODD4C/wO+j7cX1z69kV5gOzI87u3OcUinANaW8=
Expand Down Expand Up @@ -229,6 +233,7 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU=
github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
Expand Down
2 changes: 1 addition & 1 deletion pkg/consuldp/consul_dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"net/http"
"strings"

"github.com/armon/go-metrics"
"github.com/hashicorp/consul-server-connection-manager/discovery"
"github.com/hashicorp/consul/proto-public/pbdataplane"
"github.com/hashicorp/consul/proto-public/pbdns"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-metrics"
"google.golang.org/grpc"

"github.com/hashicorp/consul-dataplane/pkg/dns"
Expand Down
6 changes: 3 additions & 3 deletions pkg/consuldp/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"sync"
"time"

"github.com/armon/go-metrics"
"github.com/armon/go-metrics/datadog"
"github.com/armon/go-metrics/prometheus"
"github.com/hashicorp/consul-server-connection-manager/discovery"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-metrics"
"github.com/hashicorp/go-metrics/datadog"
"github.com/hashicorp/go-metrics/prometheus"
"github.com/hashicorp/go-multierror"
prom "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
Expand Down
2 changes: 1 addition & 1 deletion pkg/consuldp/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"testing"
"time"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics"
"github.com/stretchr/testify/require"

"github.com/hashicorp/consul-dataplane/internal/bootstrap"
Expand Down
2 changes: 1 addition & 1 deletion pkg/consuldp/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package consuldp

import "github.com/armon/go-metrics/prometheus"
import "github.com/hashicorp/go-metrics/prometheus"

var gauges = []prometheus.GaugeDefinition{
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/consuldp/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"net"
"strings"

"github.com/armon/go-metrics"
"github.com/hashi-derek/grpc-proxy/proxy"
"github.com/hashicorp/go-metrics"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
Expand Down
2 changes: 1 addition & 1 deletion pkg/metrics-cache/metricscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"sync/atomic"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics"
)

type metric struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/metrics-cache/metricscache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics"
"github.com/stretchr/testify/require"
)

Expand Down
Loading