Skip to content

Commit b86453a

Browse files
Merge pull request #208 from Shopify/fix/statsd-client
Updating client version for statsd
2 parents 402d74e + 9e2da93 commit b86453a

File tree

9 files changed

+57
-33
lines changed

9 files changed

+57
-33
lines changed

.github/workflows/go.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
uses: actions/[email protected]
2020

2121
- name: golangci-lint
22-
uses: golangci/golangci-lint-action@v3.2.0
22+
uses: golangci/golangci-lint-action@v3
2323
with:
24-
version: v1.49.0
24+
version: v1.55.2
2525

2626
mod-tidy:
2727
name: Go Mod Tidy
@@ -57,16 +57,17 @@ jobs:
5757
strategy:
5858
matrix:
5959
go-version:
60-
- 1.17.x
61-
- 1.18.x
62-
- 1.19.x
60+
- 1.18.x # EOL: 01 Feb 2023
61+
- 1.19.x # EOL: 08 Aug 2023
62+
- 1.20.x
63+
- 1.21.x
6364

6465
steps:
6566
- name: Checkout
66-
uses: actions/checkout@v3.1.0
67+
uses: actions/checkout@v3
6768

6869
- name: Setup go
69-
uses: actions/setup-go@v3.3.0
70+
uses: actions/setup-go@v3
7071
with:
7172
go-version: ${{ matrix.go-version }}
7273

.golangci.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@ output:
1313

1414
linters:
1515
enable:
16-
- depguard
1716
- dupl
1817
- goconst
1918
- gocritic
2019
- gofmt
2120
- goimports
22-
- golint
2321
- gosec
2422
- govet
2523
- lll
26-
- maligned
2724
- megacheck
2825
- misspell
2926
- nakedret
@@ -37,7 +34,7 @@ linters-settings:
3734
threshold: 100
3835
goconst:
3936
min-len: 2
40-
min-occurrences: 2
37+
min-occurrences: 3 # now is inclusive
4138
goimports:
4239
# put imports beginning with prefix after 3rd-party packages;
4340
# it's a comma-separated list of prefixes

bin/style

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Style
88
class << self
99
INSTALLER_URL = 'https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh'
1010
EXECUTABLE = 'golangci-lint'
11-
VERSION = '1.49.0'
11+
VERSION = '1.55.2'
1212
VERSION_TAG = "v#{VERSION}"
1313

1414
def call

dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: goose
22

33
up:
44
- go:
5-
version: "1.19.2"
5+
version: "1.21.4"
66
modules: true
77

88
commands:

go.mod

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ module github.com/Shopify/goose
33
go 1.15
44

55
require (
6-
github.com/DataDog/datadog-go v4.8.1+incompatible
7-
github.com/Microsoft/go-winio v0.5.0 // indirect
6+
github.com/DataDog/datadog-go/v5 v5.3.0
87
github.com/bugsnag/bugsnag-go/v2 v2.1.1
98
github.com/bugsnag/panicwrap v1.3.4
109
github.com/google/pprof v0.0.0-20210804190019-f964ff605595

go.sum

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/DataDog/datadog-go v4.8.1+incompatible h1:KgnZAqwHyxgl6Fdhu2GtdZT7xFizdUBhDI05Wly0zg0=
2-
github.com/DataDog/datadog-go v4.8.1+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
1+
github.com/DataDog/datadog-go/v5 v5.3.0 h1:2q2qjFOb3RwAZNU+ez27ZVDwErJv5/VpbBPprz7Z+s8=
2+
github.com/DataDog/datadog-go/v5 v5.3.0/go.mod h1:XRDJk1pTc00gm+ZDiBKsjh7oOOtJfYfglVCmFb8C2+Q=
33
github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU=
44
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
55
github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y=
@@ -19,6 +19,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
1919
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2020
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
2121
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
22+
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
2223
github.com/google/pprof v0.0.0-20210804190019-f964ff605595 h1:uNrRgpnKjTfxu4qHaZAAs3eKTYV1EzGF3dAykpnxgDE=
2324
github.com/google/pprof v0.0.0-20210804190019-f964ff605595/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
2425
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
@@ -56,22 +57,41 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
5657
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
5758
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
5859
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
60+
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
61+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
62+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
63+
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
64+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
65+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
66+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
5967
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c=
6068
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
69+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
6170
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
6271
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
72+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
73+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6374
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6475
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6576
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6677
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
78+
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6779
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
80+
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6881
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 h1:c8PlLMqBbOHoqtjteWm5/kbe6rNY2pbRfbIMVnepueo=
6982
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7083
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
84+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
85+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
7186
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
7287
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
7388
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
7489
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
90+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
91+
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
92+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
93+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
94+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
7595
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
7696
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
7797
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

srvutil/metrics_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"github.com/Shopify/goose/statsd"
2323
)
2424

25+
const httpScheme = "http://"
26+
2527
func TestRequestMetricsMiddleware(t *testing.T) {
2628
var recordedTags []string
2729
statsd.SetBackend(statsd.NewForwardingBackend(func(_ context.Context, mType string, name string, value interface{}, tags []string, _ float64) error {
@@ -58,7 +60,7 @@ func TestRequestMetricsMiddleware(t *testing.T) {
5860
defer s.Tomb().Kill(nil)
5961
safely.Run(s)
6062

61-
u := "http://" + s.Addr().String() + "/hello/world"
63+
u := httpScheme + s.Addr().String() + "/hello/world"
6264

6365
req, err := http.NewRequest("GET", u, nil)
6466
req.Header.Set("Authorization", "secret")

srvutil/server_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func ExampleNewServer() {
3838
defer s.Tomb().Kill(nil)
3939
safely.Run(s)
4040

41-
u := "http://" + s.Addr().String() + "/hello/world"
41+
u := httpScheme + s.Addr().String() + "/hello/world"
4242

4343
res, _ := http.Get(u)
4444
io.Copy(os.Stdout, res.Body)
@@ -64,7 +64,7 @@ func TestNewServer(t *testing.T) {
6464
defer s.Tomb().Kill(nil)
6565
safely.Run(s)
6666

67-
u := "http://" + s.Addr().String()
67+
u := httpScheme + s.Addr().String()
6868
t.Logf("test server running on %s", u)
6969

7070
assert.Contains(t, logOutput.String(), "level=info msg=\"starting server\" bind=\"127.0.0.1:0\"")
@@ -127,7 +127,7 @@ func TestNewServerFromFactory(t *testing.T) {
127127
defer s.Tomb().Kill(nil)
128128
safely.Run(s)
129129

130-
u := "http://" + s.Addr().String()
130+
u := httpScheme + s.Addr().String()
131131
t.Logf("test server running on %s", u)
132132

133133
assert.Contains(t, logOutput.String(), "level=info msg=\"starting server\" bind=\"127.0.0.1:0\"")
@@ -205,7 +205,7 @@ func TestStoppableKeepaliveListener_Accept(t *testing.T) {
205205
s := NewServer(tb, "127.0.0.1:0", sl)
206206
safely.Run(s)
207207

208-
u := "http://" + s.Addr().String()
208+
u := httpScheme + s.Addr().String()
209209
t.Logf("test server running on %s", u)
210210

211211
done := make(chan struct{})

statsd/datadog_backend.go

+16-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"time"
66

7-
"github.com/DataDog/datadog-go/statsd"
7+
"github.com/DataDog/datadog-go/v5/statsd"
88
)
99

1010
// NewDatadogBackend instantiates a new datadog/statsd connection. When running
@@ -16,13 +16,18 @@ import (
1616
// `tags` is a set of tags that will be included with every metric submitted.
1717
// STATSD_DEFAULT_TAGS env variable will be read automatically and added to default tags.
1818
func NewDatadogBackend(endpoint, namespace string, tags []string) (Backend, error) {
19-
client, err := statsd.New(endpoint)
19+
defaultTags := append(defaultTagsFromEnv(), tags...)
20+
client, err := statsd.New(
21+
endpoint,
22+
statsd.WithNamespace(namespace),
23+
statsd.WithTags(defaultTags),
24+
statsd.WithoutTelemetry(),
25+
statsd.WithoutOriginDetection(),
26+
statsd.WithClientSideAggregation(),
27+
)
2028
if err != nil {
2129
return nil, err
2230
}
23-
client.Namespace = namespace
24-
defaultTags := append(defaultTagsFromEnv(), tags...)
25-
client.Tags = defaultTags
2631
return &datadogBackend{
2732
client: client,
2833
}, nil
@@ -32,26 +37,26 @@ type datadogBackend struct {
3237
client *statsd.Client
3338
}
3439

35-
func (b *datadogBackend) Gauge(ctx context.Context, name string, value float64, tags []string, rate float64) error {
40+
func (b *datadogBackend) Gauge(_ context.Context, name string, value float64, tags []string, rate float64) error {
3641
return b.client.Gauge(name, value, tags, rate)
3742
}
3843

39-
func (b *datadogBackend) Count(ctx context.Context, name string, value int64, tags []string, rate float64) error {
44+
func (b *datadogBackend) Count(_ context.Context, name string, value int64, tags []string, rate float64) error {
4045
return b.client.Count(name, value, tags, rate)
4146
}
4247

43-
func (b *datadogBackend) Histogram(ctx context.Context, name string, value float64, tags []string, rate float64) error {
48+
func (b *datadogBackend) Histogram(_ context.Context, name string, value float64, tags []string, rate float64) error {
4449
return b.client.Histogram(name, value, tags, rate)
4550
}
4651

47-
func (b *datadogBackend) Distribution(ctx context.Context, name string, value float64, tags []string, rate float64) error {
52+
func (b *datadogBackend) Distribution(_ context.Context, name string, value float64, tags []string, rate float64) error {
4853
return b.client.Distribution(name, value, tags, rate)
4954
}
5055

51-
func (b *datadogBackend) Set(ctx context.Context, name string, value string, tags []string, rate float64) error {
56+
func (b *datadogBackend) Set(_ context.Context, name string, value string, tags []string, rate float64) error {
5257
return b.client.Set(name, value, tags, rate)
5358
}
5459

55-
func (b *datadogBackend) Timing(ctx context.Context, name string, value time.Duration, tags []string, rate float64) error {
60+
func (b *datadogBackend) Timing(_ context.Context, name string, value time.Duration, tags []string, rate float64) error {
5661
return b.client.Timing(name, value, tags, rate)
5762
}

0 commit comments

Comments
 (0)