diff --git a/.github/config/super-linter.env b/.github/config/super-linter.env index 2c587e11..8e7f9397 100644 --- a/.github/config/super-linter.env +++ b/.github/config/super-linter.env @@ -11,8 +11,8 @@ VALIDATE_BIOME_LINT=false VALIDATE_CHECKOV=false VALIDATE_DOCKERFILE_HADOLINT=false VALIDATE_GIT_COMMITLINT=false -# times out -VALIDATE_GO_MODULES=false +# golangci-lint (non-module mode) can't handle two Go modules; GO_MODULES covers this +VALIDATE_GO=false # we have many duplicate code in our codebase for demo purposes VALIDATE_JSCPD=false # conflicts with black @@ -27,8 +27,8 @@ VALIDATE_TRIVY=false FIX_CSHARP=true FIX_ENV=true -FIX_GO=true FIX_GOOGLE_JAVA_FORMAT=true +FIX_GO_MODULES=true FIX_JAVASCRIPT_PRETTIER=true FIX_JSON=true FIX_JSONC=true diff --git a/examples/go/main.go b/examples/go/main.go index 944dee15..09e36bf3 100644 --- a/examples/go/main.go +++ b/examples/go/main.go @@ -68,9 +68,14 @@ func newHTTPHandler() http.Handler { // handleFunc is a replacement for mux.HandleFunc // which enriches the handler's HTTP instrumentation with the pattern as the http.route. + // + // NOTE: otelhttp.WithRouteTag is marked deprecated, claiming that http.route is + // automatically extracted from http.Request.Pattern (Go 1.22+). However, as of + // otelhttp v0.64.0 this does not work when otelhttp wraps a ServeMux: the + // http.route attribute is read at span creation time, before the ServeMux has + // routed the request and populated r.Pattern. WithRouteTag is still needed. handleFunc := func(pattern string, handlerFunc func(http.ResponseWriter, *http.Request)) { - // Configure the "http.route" for the HTTP instrumentation. - handler := otelhttp.WithRouteTag(pattern, http.HandlerFunc(handlerFunc)) + handler := otelhttp.WithRouteTag(pattern, http.HandlerFunc(handlerFunc)) //nolint:staticcheck mux.Handle(pattern, handler) } diff --git a/examples/go/otel.go b/examples/go/otel.go index 7cc129c8..ff7a36d1 100644 --- a/examples/go/otel.go +++ b/examples/go/otel.go @@ -37,12 +37,12 @@ func setupOTelSDK(ctx context.Context) (shutdown func(context.Context) error, er // The errors from the calls are joined. // Each registered cleanup will be invoked once. shutdown = func(ctx context.Context) error { - var err error + var errs error for _, fn := range shutdownFuncs { - err = errors.Join(err, fn(ctx)) + errs = errors.Join(errs, fn(ctx)) } shutdownFuncs = nil - return err + return errs } // handleErr calls shutdown for cleanup and makes sure that all errors are returned. diff --git a/examples/go/rolldice.go b/examples/go/rolldice.go index e82857e9..10d54f27 100644 --- a/examples/go/rolldice.go +++ b/examples/go/rolldice.go @@ -39,8 +39,8 @@ func roll() int { // simulate a long operation // busy wait to make sure it's shown in the flame graph start := time.Now() + //nolint:revive // intentional busy wait for flame graph demo for time.Since(start) < 1*time.Second { - // busy wait } //nolint:gosec