Skip to content

Commit

Permalink
[gomodules] Update imports to match go.mod (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
mway authored Aug 30, 2021
1 parent 3e0027a commit bd44280
Show file tree
Hide file tree
Showing 39 changed files with 141 additions and 249 deletions.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies:
go install ./vendor/github.com/golang/lint/golint

.PHONY: lint
lint:
lint: gomodtidy
@rm -rf lint.log
@echo "Checking formatting..."
@gofmt -d -s $(PKG_FILES) 2>&1 | grep -v '$(LINT_IGNORE)' | tee lint.log
Expand All @@ -35,6 +35,15 @@ lint:
@./check_license.sh | grep -v '$(LICENSE_IGNORE)' | tee -a lint.log
@[ ! -s lint.log ]

.PHONY: gomodtidy
gomodtidy: go.mod go.sum
go mod tidy
@if ! git diff --quiet $^; then \
echo "go mod tidy changed files:" && \
git status --porcelain $^ && \
false; \
fi

.PHONY: test
test:
go test -race -v $(PKGS)
Expand Down
2 changes: 1 addition & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"fmt"
"time"

"github.com/uber-go/tally"
tally "github.com/uber-go/tally/v4"
)

type printStatsReporter struct{}
Expand Down
4 changes: 3 additions & 1 deletion instrument/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

package instrument

import "github.com/uber-go/tally"
import (
tally "github.com/uber-go/tally/v4"
)

const (
resultType = "result_type"
Expand Down
2 changes: 1 addition & 1 deletion instrument/call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"testing"
"time"

"github.com/uber-go/tally"
"github.com/uber-go/tally/v4"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
4 changes: 2 additions & 2 deletions internal/cache/tag_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ package cache
import (
"sync"

"github.com/uber-go/tally/internal/identity"
m3thrift "github.com/uber-go/tally/m3/thrift/v2"
"github.com/uber-go/tally/v4/internal/identity"
m3thrift "github.com/uber-go/tally/v4/m3/thrift/v2"
)

// TagCache is an identity.Accumulator-based tag cache.
Expand Down
2 changes: 1 addition & 1 deletion internal/identity/accumulator_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"fmt"
"testing"

"github.com/uber-go/tally/internal/identity"
"github.com/uber-go/tally/v4/internal/identity"
)

func BenchmarkAccumulator_StringStringMap(b *testing.B) {
Expand Down
3 changes: 1 addition & 2 deletions m3/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ package m3
import (
"testing"

"github.com/uber-go/tally/m3/thriftudp"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber-go/tally/v4/m3/thriftudp"
)

func TestConfigSimple(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion m3/customtransports/buffered_read_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package customtransport
import (
"bytes"

"github.com/uber-go/tally/thirdparty/github.com/apache/thrift/lib/go/thrift"
"github.com/uber-go/tally/v4/thirdparty/github.com/apache/thrift/lib/go/thrift"
)

// TBufferedReadTransport is a thrift.TTransport that reads from a buffer
Expand Down
2 changes: 1 addition & 1 deletion m3/customtransports/m3_calc_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/uber-go/tally/thirdparty/github.com/apache/thrift/lib/go/thrift"
"github.com/uber-go/tally/v4/thirdparty/github.com/apache/thrift/lib/go/thrift"
)

// Make sure that TCalcTransport implements TRichTransport.
Expand Down
8 changes: 4 additions & 4 deletions m3/example/local_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
"net"
"sync/atomic"

"github.com/uber-go/tally/m3"
customtransport "github.com/uber-go/tally/m3/customtransports"
m3thrift "github.com/uber-go/tally/m3/thrift/v1"
"github.com/uber-go/tally/thirdparty/github.com/apache/thrift/lib/go/thrift"
"github.com/uber-go/tally/v4/m3"
customtransport "github.com/uber-go/tally/v4/m3/customtransports"
m3thrift "github.com/uber-go/tally/v4/m3/thrift/v1"
"github.com/uber-go/tally/v4/thirdparty/github.com/apache/thrift/lib/go/thrift"
)

type batchCallback func(batch *m3thrift.MetricBatch)
Expand Down
6 changes: 3 additions & 3 deletions m3/example/m3_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
"os"
"time"

"github.com/uber-go/tally"
"github.com/uber-go/tally/m3"
m3thrift "github.com/uber-go/tally/m3/thrift/v1"
tally "github.com/uber-go/tally/v4"
"github.com/uber-go/tally/v4/m3"
m3thrift "github.com/uber-go/tally/v4/m3/thrift/v1"

validator "gopkg.in/validator.v2"
yaml "gopkg.in/yaml.v2"
Expand Down
12 changes: 6 additions & 6 deletions m3/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import (
"time"

"github.com/pkg/errors"
"github.com/uber-go/tally"
"github.com/uber-go/tally/internal/cache"
customtransport "github.com/uber-go/tally/m3/customtransports"
m3thrift "github.com/uber-go/tally/m3/thrift/v2"
"github.com/uber-go/tally/m3/thriftudp"
"github.com/uber-go/tally/thirdparty/github.com/apache/thrift/lib/go/thrift"
tally "github.com/uber-go/tally/v4"
"github.com/uber-go/tally/v4/internal/cache"
customtransport "github.com/uber-go/tally/v4/m3/customtransports"
m3thrift "github.com/uber-go/tally/v4/m3/thrift/v2"
"github.com/uber-go/tally/v4/m3/thriftudp"
"github.com/uber-go/tally/v4/thirdparty/github.com/apache/thrift/lib/go/thrift"
"go.uber.org/atomic"
)

Expand Down
2 changes: 1 addition & 1 deletion m3/reporter_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"testing"
"time"

"github.com/uber-go/tally"
tally "github.com/uber-go/tally/v4"
)

func BenchmarkNewMetric(b *testing.B) {
Expand Down
16 changes: 9 additions & 7 deletions m3/reporter_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ import (
"os"
"os/exec"
"path"
"path/filepath"
"sync"
"testing"

"github.com/stretchr/testify/require"
)

var (
mainFileFmt = `
var mainFileFmt = `
package main
import (
"time"
"github.com/uber-go/tally"
"github.com/uber-go/tally/m3"
tally "github.com/uber-go/tally/v4"
"github.com/uber-go/tally/v4/m3"
)
func main() {
Expand All @@ -63,7 +63,6 @@ func main() {
scope.Timer("my-timer").Record(456 * time.Millisecond)
}
`
)

// TestIntegrationProcessFlushOnExit tests whether data is correctly flushed
// when the scope is closed for shortly lived programs
Expand All @@ -74,10 +73,13 @@ func TestIntegrationProcessFlushOnExit(t *testing.T) {
}

func testProcessFlushOnExit(t *testing.T, i int) {
dir, err := ioutil.TempDir("", "foo")
dir, err := os.MkdirTemp(".", "foo")
require.NoError(t, err)
defer os.RemoveAll(dir)

dir, err = filepath.Abs(dir)
require.NoError(t, err)

var wg sync.WaitGroup
server := newFakeM3Server(t, &wg, true, Compact)
go server.Serve()
Expand All @@ -86,7 +88,7 @@ func testProcessFlushOnExit(t *testing.T, i int) {
mainFile := path.Join(dir, "main.go")
mainFileContents := fmt.Sprintf(mainFileFmt, server.Addr)

fileErr := ioutil.WriteFile(mainFile, []byte(mainFileContents), 0666)
fileErr := ioutil.WriteFile(mainFile, []byte(mainFileContents), 0o666)
require.NoError(t, fileErr)

binary := path.Join(dir, "m3testemit")
Expand Down
16 changes: 9 additions & 7 deletions m3/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import (
"testing"
"time"

"github.com/uber-go/tally"
customtransport "github.com/uber-go/tally/m3/customtransports"
m3thrift "github.com/uber-go/tally/m3/thrift/v2"
"github.com/uber-go/tally/m3/thriftudp"
"github.com/uber-go/tally/thirdparty/github.com/apache/thrift/lib/go/thrift"
tally "github.com/uber-go/tally/v4"
customtransport "github.com/uber-go/tally/v4/m3/customtransports"
m3thrift "github.com/uber-go/tally/v4/m3/thrift/v2"
"github.com/uber-go/tally/v4/m3/thriftudp"
"github.com/uber-go/tally/v4/thirdparty/github.com/apache/thrift/lib/go/thrift"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -49,8 +49,10 @@ const (
shortInterval = 10 * time.Millisecond
)

var localListenAddr = &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}
var defaultCommonTags = map[string]string{"env": "test", "host": "test"}
var (
localListenAddr = &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}
defaultCommonTags = map[string]string{"env": "test", "host": "test"}
)

var protocols = []Protocol{Compact, Binary}

Expand Down
8 changes: 4 additions & 4 deletions m3/resource_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
package m3

import (
"github.com/uber-go/tally"
customtransport "github.com/uber-go/tally/m3/customtransports"
m3thrift "github.com/uber-go/tally/m3/thrift/v2"
"github.com/uber-go/tally/thirdparty/github.com/apache/thrift/lib/go/thrift"
tally "github.com/uber-go/tally/v4"
customtransport "github.com/uber-go/tally/v4/m3/customtransports"
m3thrift "github.com/uber-go/tally/v4/m3/thrift/v2"
"github.com/uber-go/tally/v4/thirdparty/github.com/apache/thrift/lib/go/thrift"
)

const (
Expand Down
5 changes: 2 additions & 3 deletions m3/resource_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ package m3
import (
"testing"

m3thrift "github.com/uber-go/tally/m3/thrift/v2"
"github.com/uber-go/tally/thirdparty/github.com/apache/thrift/lib/go/thrift"

"github.com/stretchr/testify/require"
m3thrift "github.com/uber-go/tally/v4/m3/thrift/v2"
"github.com/uber-go/tally/v4/thirdparty/github.com/apache/thrift/lib/go/thrift"
)

func TestM3ResourcePoolMetric(t *testing.T) {
Expand Down
36 changes: 17 additions & 19 deletions m3/sanitize.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,22 @@
package m3

import (
"github.com/uber-go/tally"
tally "github.com/uber-go/tally/v4"
)

var (
// DefaultSanitizerOpts are the options for the default M3 sanitizer.
DefaultSanitizerOpts = tally.SanitizeOptions{
NameCharacters: tally.ValidCharacters{
Ranges: tally.AlphanumericRange,
Characters: tally.UnderscoreDashDotCharacters,
},
KeyCharacters: tally.ValidCharacters{
Ranges: tally.AlphanumericRange,
Characters: tally.UnderscoreDashCharacters,
},
ValueCharacters: tally.ValidCharacters{
Ranges: tally.AlphanumericRange,
Characters: tally.UnderscoreDashDotCharacters,
},
ReplacementCharacter: tally.DefaultReplacementCharacter,
}
)
// DefaultSanitizerOpts are the options for the default M3 sanitizer.
var DefaultSanitizerOpts = tally.SanitizeOptions{
NameCharacters: tally.ValidCharacters{
Ranges: tally.AlphanumericRange,
Characters: tally.UnderscoreDashDotCharacters,
},
KeyCharacters: tally.ValidCharacters{
Ranges: tally.AlphanumericRange,
Characters: tally.UnderscoreDashCharacters,
},
ValueCharacters: tally.ValidCharacters{
Ranges: tally.AlphanumericRange,
Characters: tally.UnderscoreDashDotCharacters,
},
ReplacementCharacter: tally.DefaultReplacementCharacter,
}
3 changes: 1 addition & 2 deletions m3/scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import (
"testing"
"time"

"github.com/uber-go/tally"

"github.com/stretchr/testify/require"
tally "github.com/uber-go/tally/v4"
)

var commonTags = map[string]string{"env": "test"}
Expand Down
8 changes: 4 additions & 4 deletions m3/thrift/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# thrift_version := v1.0.0

gen-thrift:
@thrift --gen go:thrift_import="github.com/uber-go/tally/thirdparty/github.com/apache/thrift/lib/go/thrift" -out . v1/v1.thrift && rm -rf v1/m3-remote
@thrift --gen go:thrift_import="github.com/uber-go/tally/v4/thirdparty/github.com/apache/thrift/lib/go/thrift" -out . v1/v1.thrift && rm -rf v1/m3-remote
@echo Generated v1 Go Thrift in metrics/m3/thrift/v1.
@thrift --gen go:thrift_import="github.com/uber-go/tally/thirdparty/github.com/apache/thrift/lib/go/thrift" -out . v2/v2.thrift && rm -rf v2/m3-remote
@thrift --gen go:thrift_import="github.com/uber-go/tally/v4/thirdparty/github.com/apache/thrift/lib/go/thrift" -out . v2/v2.thrift && rm -rf v2/m3-remote
@echo Generated v2 Go Thrift in metrics/m3/thrift/v2.
@git apply thrift.diff
@echo Applied thrift.diff.
22 changes: 1 addition & 21 deletions m3/thrift/v1/constants.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bd44280

Please sign in to comment.