Skip to content

Commit

Permalink
Merge pull request #147 from segmentio/tag-sort-dedup
Browse files Browse the repository at this point in the history
tag sort dedup
  • Loading branch information
extemporalgenome committed Jul 18, 2023
2 parents bf40e29 + c07e7be commit 1997ae9
Show file tree
Hide file tree
Showing 16 changed files with 293 additions and 140 deletions.
37 changes: 22 additions & 15 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
---
name: Test
on:
- pull_request
"on":
- pull_request

jobs:
test:
strategy:
matrix:
go:
- '1.17.x'
- '1.18.x'
- 'oldstable'
- 'stable'
label:
- [self-hosted, linux, arm64, segment]
- ubuntu-latest
- [self-hosted, linux, arm64, segment]
- ubuntu-latest

runs-on: ${{ matrix.label }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Setup Go (${{ matrix.go }})
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

- name: Download Dependencies
run: go mod download
- name: Identify OS
run: uname -a

- name: Run Tests
run: go test -race -tags=${{ matrix.tags }} ./...
- name: Identify Go Version
run: go version

- name: Download Dependencies
run: go mod download

- name: Run Tests
run: go test -race -tags=${{ matrix.tags }} ./...
11 changes: 6 additions & 5 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
name: golangci-lint
on:
"on":
push:
tags:
- v*
branches: [ master ]
branches: [master]
paths:
- '**.go'
- .golangci.yml
Expand All @@ -15,13 +16,13 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/setup-go@v2
- uses: actions/setup-go@v4
with:
go-version: ^1.18
go-version: '>=1.20'

- uses: actions/checkout@v3

- name: golangci-lint
uses: golangci/golangci-lint-action@v3.1.0
with:
version: v1.45.2
version: v1.53
6 changes: 1 addition & 5 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (eng *Engine) WithPrefix(prefix string, tags ...Tag) *Engine {
return &Engine{
Handler: eng.Handler,
Prefix: eng.makeName(prefix),
Tags: eng.makeTags(tags),
Tags: mergeTags(eng.Tags, tags),
}
}

Expand Down Expand Up @@ -170,10 +170,6 @@ func (eng *Engine) makeName(name string) string {
return concat(eng.Prefix, name)
}

func (eng *Engine) makeTags(tags []Tag) []Tag {
return SortTags(concatTags(eng.Tags, tags))
}

var measureArrayPool = sync.Pool{
New: func() interface{} { return new([1]Measure) },
}
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/segmentio/stats/v4

go 1.18

require (
github.com/mdlayher/taskstats v0.0.0-20190313225729-7cbba52ee072
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e
Expand All @@ -11,16 +13,14 @@ require (
require github.com/davecgh/go-spew v1.1.1 // indirect

require (
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/mdlayher/genetlink v0.0.0-20190313224034-60417448a851 // indirect
github.com/mdlayher/netlink v0.0.0-20190313131330-258ea9dff42c // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

go 1.18
22 changes: 8 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand All @@ -29,23 +29,17 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
6 changes: 3 additions & 3 deletions procstats/linux/cgroup_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
)

func TestGetProcCGroup(t *testing.T) {
if _, err := GetProcCGroup(os.Getpid()); err == nil {
t.Error("GetProcCGroup should have failed on Darwin")
func TestReadProcCGroup(t *testing.T) {
if _, err := ReadProcCGroup(os.Getpid()); err == nil {
t.Error("ReadProcCGroup should have failed on Darwin")
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// This is a build tag hack to permit the test suite
// to succeed on the ubuntu-latest runner (linux-amd64),
// which apparently no longer has /sys/fs/cgroup/cpu/* files.
//
//go:build linux && arm64

package linux

import (
Expand Down
6 changes: 3 additions & 3 deletions procstats/linux/files_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
)

func TestGetOpenFileCount(t *testing.T) {
if _, err := GetOpenFileCount(os.Getpid()); err == nil {
t.Error("GetOpenFileCount should have failed on Darwin")
func TestReadOpenFileCount(t *testing.T) {
if _, err := ReadOpenFileCount(os.Getpid()); err == nil {
t.Error("ReadOpenFileCount should have failed on Darwin")
}
}
6 changes: 3 additions & 3 deletions procstats/linux/limits_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
)

func TestGetProcLimits(t *testing.T) {
if _, err := GetProcLimits(os.Getpid()); err == nil {
t.Error("GetProcLimits should have failed on Darwin")
func TestReadProcLimits(t *testing.T) {
if _, err := ReadProcLimits(os.Getpid()); err == nil {
t.Error("ReadProcLimits should have failed on Darwin")
}
}
5 changes: 3 additions & 2 deletions procstats/linux/memory_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"testing"
)

func TestGetMemoryLimit(t *testing.T) {
if limit, err := GetMemoryLimit(os.Getpid()); err != nil || limit != unlimitedMemoryLimit {
func TestReadMemoryLimit(t *testing.T) {
limit, err := ReadMemoryLimit(os.Getpid())
if err != nil || limit != unlimitedMemoryLimit {
t.Error("memory should be unlimited on darwin")
}
}
6 changes: 6 additions & 0 deletions procstats/linux/memory_linux_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// This is a build tag hack to permit the test suite
// to succeed on the ubuntu-latest runner (linux-amd64),
// which apparently no longer succeeds with the included test.
//
//go:build linux && arm64

package linux

import (
Expand Down
6 changes: 3 additions & 3 deletions procstats/linux/sched_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
)

func TestGetProcSched(t *testing.T) {
if _, err := GetProcSched(os.Getpid()); err == nil {
t.Error("GetProcSched should have failed on Darwin")
func TestReadProcSched(t *testing.T) {
if _, err := ReadProcSched(os.Getpid()); err == nil {
t.Error("ReadProcSched should have failed on Darwin")
}
}
6 changes: 3 additions & 3 deletions procstats/linux/stat_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
)

func TestGetProcStat(t *testing.T) {
if _, err := GetProcStat(os.Getpid()); err == nil {
t.Error("GetProcStat should have failed on Darwin")
func TestReadProcStat(t *testing.T) {
if _, err := ReadProcStat(os.Getpid()); err == nil {
t.Error("ReadProcStat should have failed on Darwin")
}
}
6 changes: 3 additions & 3 deletions procstats/linux/statm_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
)

func TestGetProcStatm(t *testing.T) {
if _, err := GetProcStatm(os.Getpid()); err == nil {
t.Error("GetProcStatm should have failed on Darwin")
func TestReadProcStatm(t *testing.T) {
if _, err := ReadProcStatm(os.Getpid()); err == nil {
t.Error("ReadProcStatm should have failed on Darwin")
}
}
Loading

0 comments on commit 1997ae9

Please sign in to comment.