Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/go.opentelemetry.io/ot…
Browse files Browse the repository at this point in the history
…el/trace-1.29.0
  • Loading branch information
ktong authored Aug 26, 2024
2 parents 3f172f3 + 9ad140a commit c5e7d4c
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 63 deletions.
26 changes: 3 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,10 @@ jobs:
matrix:
module: [
'', 'otlp', 'gcp',
'grpc', 'examples/grpc'
]
go-version: [ 'stable', 'oldstable' ]
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: "**/go.sum"
- name: Race Test
run: go test -v -shuffle=on -count=10 -race ./...
working-directory: ${{ matrix.module }}
- name: Test
run: go test -shuffle=on -v ./...
working-directory: ${{ matrix.module }}
test-http:
strategy:
matrix:
module: [
'grpc', 'examples/grpc',
'http', 'examples/http'
]
go-version: [ 'stable' ]
go-version: [ 'stable', 'oldstable' ]
name: Test
runs-on: ubuntu-latest
steps:
Expand All @@ -55,7 +35,7 @@ jobs:
if: ${{ always() }}
runs-on: ubuntu-latest
name: All Tests
needs: [test, test-http]
needs: test
steps:
- name: Check test matrix status
if: ${{ needs.test.result != 'success' }}
Expand Down
7 changes: 5 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ linters-settings:
local-prefixes: github.com/nil-go/nilgo
gomoddirectives:
replace-local: true
gosec:
excludes:
# Flags for potentially-unsafe casting of ints, similar problem to globally-disabled G103
- G115
govet:
enable:
- shadow
Expand All @@ -38,7 +42,7 @@ linters:
- canonicalheader
- containedctx
- contextcheck
# copyloopvar
- copyloopvar
- cyclop
- decorder
# depguard
Expand All @@ -51,7 +55,6 @@ linters:
- errchkjson
- errname
- errorlint
- exportloopref
- exhaustive
# exhaustruct
- fatcontext
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Removed

- Remove support for Golang 1.21 (#122).

## [0.2.0] - 2024-05-17

### Added

- Support Open Telemetry with OTLP exporters (#61).

## [0.1.0] - 2024-05-07
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nil-go/nilgo/examples/grpc

go 1.21
go 1.22

require (
cloud.google.com/go/compute/metadata v0.3.0
Expand Down
22 changes: 12 additions & 10 deletions examples/http/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ func main() {
}
})
server := &http.Server{
Handler: otelhttp.NewHandler(mux, "", otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string {
if operation != "" {
return operation
}
Handler: otelhttp.NewHandler(mux, "", otelhttp.WithSpanNameFormatter(
func(operation string, req *http.Request) string {
if operation != "" {
return operation
}

method := r.Method
if method == "" {
method = "GET"
}
method := req.Method
if method == "" {
method = "GET"
}

return method + " " + r.URL.Path
})),
return method + " " + req.URL.Path
}),
),
ReadTimeout: time.Second,
}
runs = append(runs,
Expand Down
2 changes: 1 addition & 1 deletion gcp/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nil-go/nilgo/gcp

go 1.21
go 1.22

require (
cloud.google.com/go/compute/metadata v0.5.0
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nil-go/nilgo

go 1.21
go 1.22

require (
go.opentelemetry.io/otel v1.29.0
Expand Down
2 changes: 1 addition & 1 deletion grpc/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nil-go/nilgo/grpc

go 1.21
go 1.22

require (
github.com/nil-go/konf v1.2.2
Expand Down
5 changes: 0 additions & 5 deletions grpc/internal/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ level=ERROR msg=error
}

for _, testcase := range testcases {
testcase := testcase

t.Run(testcase.description, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -97,8 +95,6 @@ level=ERROR msg=error
}

for _, testcase := range testcases {
testcase := testcase

t.Run(testcase.description, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -178,7 +174,6 @@ func TestIsSamplingHandler(t *testing.T) {
}

for _, testcase := range testcases {
testcase := testcase
t.Run(testcase.description, func(t *testing.T) {
t.Parallel()

Expand Down
6 changes: 1 addition & 5 deletions grpc/internal/recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ func TestRecoveryUnaryInterceptor(t *testing.T) {
}

for _, testcase := range testcases {
testcase := testcase

t.Run(testcase.description, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -95,15 +93,13 @@ func TestRecoveryStreamInterceptor(t *testing.T) {
handler: func(any, grpc.ServerStream) error {
panic("panic from handler")
},
log: `level=ERROR source=/recovery_test.go:96 msg="Panic Recovered" error="panic from handler"
log: `level=ERROR source=/recovery_test.go:94 msg="Panic Recovered" error="panic from handler"
`,
err: "rpc error: code = Internal desc = ",
},
}

for _, testcase := range testcases {
testcase := testcase

t.Run(testcase.description, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func Run(server *grpc.Server, opts ...Option) func(context.Context) error { //no
var waitGroup sync.WaitGroup
waitGroup.Add(len(option.addresses))
for _, addr := range option.addresses {
addr := addr
go func() {
defer waitGroup.Done()

Expand Down
2 changes: 0 additions & 2 deletions grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ func TestRun(t *testing.T) {
}

for _, testcase := range testcases {
testcase := testcase

t.Run(testcase.description, func(t *testing.T) {
t.Parallel()

Expand Down
3 changes: 0 additions & 3 deletions http/internal/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ level=ERROR msg=error
}

for _, testcase := range testcases {
testcase := testcase

t.Run(testcase.description, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -127,7 +125,6 @@ func TestIsSamplingHandler(t *testing.T) {
}

for _, testcase := range testcases {
testcase := testcase
t.Run(testcase.description, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions http/internal/recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ func TestRecoveryInterceptor(t *testing.T) {
}

for _, testcase := range testcases {
testcase := testcase

t.Run(testcase.description, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func Run(server *http.Server, opts ...Option) func(context.Context) error { //no
}
}
for _, addr := range option.addresses {
addr := addr
go func() {
defer waitGroup.Done()

Expand Down
2 changes: 1 addition & 1 deletion otlp/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nil-go/nilgo/otlp

go 1.21
go 1.22

require (
github.com/stretchr/testify v1.9.0
Expand Down
2 changes: 0 additions & 2 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func (r Runner) Run(ctx context.Context, runs ...func(context.Context) error) er
var waitGroup sync.WaitGroup
waitGroup.Add(len(r.preRuns))
for _, run := range r.preRuns {
run := run
preRuns = append(preRuns,
func(ctx context.Context) error {
waitGroup.Done()
Expand Down Expand Up @@ -131,7 +130,6 @@ func parallel(ctx context.Context, runs ...func(context.Context) error) error {
var waitGroup sync.WaitGroup
waitGroup.Add(len(runs))
for _, run := range runs {
run := run
go func() {
defer waitGroup.Done()

Expand Down
2 changes: 0 additions & 2 deletions runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ func TestRunner_Run(t *testing.T) {
}

for _, testcase := range testcases {
testcase := testcase

var ran bool
t.Run(testcase.description, func(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit c5e7d4c

Please sign in to comment.