Skip to content

Commit 1924b42

Browse files
all: appease the linter
Turn off the thing where the tests can pass even though lint fails - it's as good as not running the linter at all. The "stats" name import next to "github.com/segmentio/stats/v5" is not necessary but was prompted by golangci-lint at one point.
1 parent 53208e5 commit 1924b42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+100
-56
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
lint:
1919
name: lint
2020
runs-on: ubuntu-latest
21-
continue-on-error: true
2221
steps:
2322
- uses: actions/setup-go@v5
2423
with:

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
test:
2+
go test -trimpath ./...
3+
4+
ci:
5+
go test -race -trimpath ./...
6+
7+
lint:
8+
golangci-lint run --config .github/workflows/golangci-lint.yml

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Monitoring
183183

184184
> 🚧 Go metrics reported with the `procstats` package were previously tagged with a
185185
> `version` label that reported the Go runtime version. This label was renamed to
186-
> `go_version` in v5.6.0.
186+
> `go_version` in v4.6.0.
187187
188188
The
189189
[github.com/segmentio/stats/procstats](https://godoc.org/github.com/segmentio/stats/procstats)
@@ -389,11 +389,11 @@ func main() {
389389
### Addendum
390390

391391
By default, the stats library will report the running go version when you
392-
invoke NewEngine() as three metrics:
392+
invoke NewEngine() as a metric:
393393

394-
- `go_version.major`
395-
- `go_version.minor`
396-
- `go_version.patch`
394+
- `go_version` with value 1 and a `tag` set to the current version.
395+
- `stats_version` with value ` and a `tag` set to the tag value of
396+
segmentio/stats.
397397

398398
Set `STATS_DISABLE_GO_VERSION_REPORTING` to `true` in your environment, or set
399399
`stats.GoVersionReportingEnabled` to `false` before collecting any metrics, to

cmd/dogstatsd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"strings"
1313
"time"
1414

15-
"github.com/segmentio/stats/v5"
15+
stats "github.com/segmentio/stats/v5"
1616
"github.com/segmentio/stats/v5/datadog"
1717
)
1818

context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
// ContextWithTags returns a new child context with the given tags. If the
9-
// parent context already has tags set on it, they are _not_ propegated into
9+
// parent context already has tags set on it, they are _not_ propagated into
1010
// the context children.
1111
func ContextWithTags(ctx context.Context, tags ...Tag) context.Context {
1212
// initialize the context reference and return a new context

datadog/append.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"strconv"
55
"strings"
66

7-
"github.com/segmentio/stats/v5"
7+
stats "github.com/segmentio/stats/v5"
88
)
99

1010
func appendMetric(b []byte, m Metric) []byte {

datadog/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99
"time"
1010

11-
"github.com/segmentio/stats/v5"
11+
stats "github.com/segmentio/stats/v5"
1212

1313
"golang.org/x/sys/unix"
1414
)

datadog/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"testing"
1212
"time"
1313

14-
"github.com/segmentio/stats/v5"
14+
stats "github.com/segmentio/stats/v5"
1515

1616
"github.com/stretchr/testify/assert"
1717
)

datadog/event.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package datadog
33
import (
44
"fmt"
55

6-
"github.com/segmentio/stats/v5"
6+
stats "github.com/segmentio/stats/v5"
77
)
88

99
// EventPriority is an enumeration providing the available datadog event

datadog/event_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package datadog
22

33
import (
4-
"github.com/segmentio/stats/v5"
4+
stats "github.com/segmentio/stats/v5"
55
)
66

77
var testEvents = []struct {

datadog/metric.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"sync"
66

7-
"github.com/segmentio/stats/v5"
7+
stats "github.com/segmentio/stats/v5"
88
)
99

1010
// MetricType is an enumeration providing symbols to represent the different

datadog/metric_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package datadog
33
import (
44
"testing"
55

6-
"github.com/segmentio/stats/v5"
6+
stats "github.com/segmentio/stats/v5"
77
)
88

99
var testMetrics = []struct {

datadog/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strconv"
66
"strings"
77

8-
"github.com/segmentio/stats/v5"
8+
stats "github.com/segmentio/stats/v5"
99
)
1010

1111
// Adapted from https://github.com/DataDog/datadog-agent/blob/6789e98a1e41e98700fa1783df62238bb23cb454/pkg/dogstatsd/parser.go#L141

datadog/serializer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12-
"github.com/segmentio/stats/v5"
12+
stats "github.com/segmentio/stats/v5"
1313
)
1414

1515
// Datagram format: https://docs.datadoghq.com/developers/dogstatsd/datagram_shell

datadog/serializer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"testing"
55
"time"
66

7-
"github.com/segmentio/stats/v5"
7+
stats "github.com/segmentio/stats/v5"
88
)
99

1010
var testMeasures = []struct {

datadog/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"testing"
1212
"time"
1313

14-
"github.com/segmentio/stats/v5"
14+
stats "github.com/segmentio/stats/v5"
1515
)
1616

1717
func TestServer(t *testing.T) {

engine.go

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"strings"
99
"sync"
1010
"time"
11+
12+
"github.com/segmentio/stats/v5/version"
1113
)
1214

1315
// An Engine carries the context for producing metrics. It is configured by
@@ -156,10 +158,30 @@ func (eng *Engine) measure(t time.Time, name string, value interface{}, ftype Fi
156158
eng.once.Do(func() {
157159
vsn := strings.TrimPrefix(runtime.Version(), "go")
158160
parts := strings.Split(vsn, ".")
159-
// this filters out weird compiled Go versions like tip.
160-
// older Go version might be "go1.13"
161+
// this filters out weird compiled Go versions like tip. len(parts)
162+
// may equal 2 because older Go version might be "go1.13"
161163
if len(parts) == 2 || len(parts) == 3 {
162-
eng.measureOne(t, "go_version", 1, Gauge, []Tag{{"go_version", vsn}}...)
164+
eng.Handler.HandleMeasures(t, Measure{
165+
Name: "go_version",
166+
Fields: []Field{{
167+
Name: "go_version",
168+
Value: intValue(1),
169+
}},
170+
Tags: []Tag{
171+
{"go_version", vsn},
172+
},
173+
},
174+
Measure{
175+
Name: "stats_version",
176+
Fields: []Field{{
177+
Name: "stats_version",
178+
Value: intValue(1),
179+
}},
180+
Tags: []Tag{
181+
{"stats_version", version.Version},
182+
},
183+
},
184+
)
163185
}
164186
})
165187
}

engine_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"testing"
99
"time"
1010

11-
"github.com/segmentio/stats/v5"
11+
stats "github.com/segmentio/stats/v5"
1212
"github.com/segmentio/stats/v5/datadog"
1313
"github.com/segmentio/stats/v5/influxdb"
1414
"github.com/segmentio/stats/v5/prometheus"

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module github.com/segmentio/stats/v5
22

33
go 1.22.0
44

5-
toolchain go1.23.1
6-
75
require (
86
github.com/mdlayher/taskstats v0.0.0-20190313225729-7cbba52ee072
97
github.com/segmentio/fasthash v1.0.3

handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"testing"
55
"time"
66

7-
"github.com/segmentio/stats/v5"
7+
stats "github.com/segmentio/stats/v5"
88
"github.com/segmentio/stats/v5/statstest"
99

1010
"github.com/stretchr/testify/assert"

httpstats/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package httpstats
33
import (
44
"net/http"
55

6-
"github.com/segmentio/stats/v5"
6+
stats "github.com/segmentio/stats/v5"
77
)
88

99
// RequestWithTags returns a shallow copy of req with its context updated to

httpstats/context_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import (
66
"net/http/httptest"
77
"testing"
88

9-
"github.com/stretchr/testify/assert"
9+
stats "github.com/segmentio/stats/v5"
1010

11-
"github.com/segmentio/stats/v5"
11+
"github.com/stretchr/testify/assert"
1212
)
1313

14-
// TestRequestContextTagPropegation verifies that the root ancestor tags are
14+
// TestRequestContextTagPropagation verifies that the root ancestor tags are
1515
// updated in the event the context or request has children. It's nearly
1616
// identical to the context_test in the stats package itself, but we want to
1717
// keep this to ensure that changes to the request context code doesn't drift
1818
// and cause bugs.
19-
func TestRequestContextTagPropegation(t *testing.T) {
19+
func TestRequestContextTagPropagation(t *testing.T) {
2020
// dummy request
2121
x := httptest.NewRequest(http.MethodGet, "http://example.com/blah", nil)
2222

httpstats/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"net/http"
77
"time"
88

9-
"github.com/segmentio/stats/v5"
9+
stats "github.com/segmentio/stats/v5"
1010
)
1111

1212
// NewHandler wraps h to produce metrics on the default engine for every request

httpstats/handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"testing"
99

10-
"github.com/segmentio/stats/v5"
10+
stats "github.com/segmentio/stats/v5"
1111
"github.com/segmentio/stats/v5/statstest"
1212
)
1313

httpstats/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"sync"
1111
"time"
1212

13-
"github.com/segmentio/stats/v5"
13+
stats "github.com/segmentio/stats/v5"
1414
)
1515

1616
func init() {

httpstats/transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net/http"
55
"time"
66

7-
"github.com/segmentio/stats/v5"
7+
stats "github.com/segmentio/stats/v5"
88
)
99

1010
// NewTransport wraps t to produce metrics on the default engine for every request

httpstats/transport_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"testing"
99

10-
"github.com/segmentio/stats/v5"
10+
stats "github.com/segmentio/stats/v5"
1111
"github.com/segmentio/stats/v5/statstest"
1212
)
1313

influxdb/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
"github.com/segmentio/objconv/json"
1616

17-
"github.com/segmentio/stats/v5"
17+
stats "github.com/segmentio/stats/v5"
1818
)
1919

2020
const (

influxdb/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"testing"
99
"time"
1010

11-
"github.com/segmentio/stats/v5"
11+
stats "github.com/segmentio/stats/v5"
1212
)
1313

1414
func DisabledTestClient(t *testing.T) {

influxdb/measure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"strconv"
55
"time"
66

7-
"github.com/segmentio/stats/v5"
7+
stats "github.com/segmentio/stats/v5"
88
)
99

1010
// AppendMeasure is a formatting routine to append the InflxDB line protocol

influxdb/measure_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"testing"
55
"time"
66

7-
"github.com/segmentio/stats/v5"
7+
stats "github.com/segmentio/stats/v5"
88
)
99

1010
var (

measure.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ func (c *measureCache) load() *map[reflect.Type][]measureFuncs {
504504
return (*map[reflect.Type][]measureFuncs)(atomic.LoadPointer(&c.cache))
505505
}
506506

507-
func (c *measureCache) compareAndSwap(old, new *map[reflect.Type][]measureFuncs) bool {
507+
func (c *measureCache) compareAndSwap(old, newPtr *map[reflect.Type][]measureFuncs) bool {
508508
return atomic.CompareAndSwapPointer(&c.cache,
509509
unsafe.Pointer(old),
510-
unsafe.Pointer(new),
510+
unsafe.Pointer(newPtr),
511511
)
512512
}

netstats/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/segmentio/vpcinfo"
1212

13-
"github.com/segmentio/stats/v5"
13+
stats "github.com/segmentio/stats/v5"
1414
)
1515

1616
func init() {

netstats/conn_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/segmentio/stats/v5"
12+
stats "github.com/segmentio/stats/v5"
1313
"github.com/segmentio/stats/v5/statstest"
1414
)
1515

netstats/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"net"
66

7-
"github.com/segmentio/stats/v5"
7+
stats "github.com/segmentio/stats/v5"
88
)
99

1010
// Handler is an interface that can be implemented by types that serve network

netstats/listener.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net"
55
"sync/atomic"
66

7-
"github.com/segmentio/stats/v5"
7+
stats "github.com/segmentio/stats/v5"
88
)
99

1010
// NewListener returns a new net.Listener which uses the stats.DefaultEngine.

0 commit comments

Comments
 (0)