From 762a06324cdc5c1392fca7fff2cd769a0062e2a0 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Sun, 27 Aug 2023 07:19:28 -0700 Subject: [PATCH] Add testing support for Go 1.21 (#4233) * Add testing support for Go 1.21 * Add PR number to changelog * Fix testing in xray sampler --- .github/workflows/ci.yml | 4 ++-- .github/workflows/create-dependabot-pr.yml | 2 +- .github/workflows/dependabot.yml | 2 +- CHANGELOG.md | 1 + README.md | 5 +++++ samplers/aws/xray/remote_sampler_config.go | 4 +++- samplers/aws/xray/remote_sampler_config_test.go | 7 ++----- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9ead98f588..bfafb8c7778 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ env: # backwards compatibility with the previous two minor releases and we # explicitly test our code for these versions so keeping this at prior # versions does not add value. - DEFAULT_GO_VERSION: "1.20" + DEFAULT_GO_VERSION: "1.21" jobs: lint: runs-on: ubuntu-latest @@ -117,7 +117,7 @@ jobs: compatibility-test: strategy: matrix: - go-version: ["1.20", 1.19] + go-version: ["1.21", "1.20", 1.19] os: [ubuntu-latest, macos-latest, windows-latest] # GitHub Actions does not support arm* architectures on default # runners. It is possible to acomplish this with a self-hosted runner diff --git a/.github/workflows/create-dependabot-pr.yml b/.github/workflows/create-dependabot-pr.yml index 29b02791535..08c00a9429b 100644 --- a/.github/workflows/create-dependabot-pr.yml +++ b/.github/workflows/create-dependabot-pr.yml @@ -10,7 +10,7 @@ jobs: - name: Install Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' - uses: actions/checkout@v3 diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 2de6b06d401..9d4e27a9e6e 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -13,7 +13,7 @@ jobs: ref: ${{ github.head_ref }} - uses: actions/setup-go@v4 with: - go-version: '^1.20.0' + go-version: '^1.21.0' - uses: evantorrie/mott-the-tidier@v1-beta id: modtidy with: diff --git a/CHANGELOG.md b/CHANGELOG.md index dfc28098000..8bfebeaa58a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `go.opentelemetry.io/contrib/exporters/autoexport` package to provide configuration of trace exporters with useful defaults and envar support. (#2753, #4100, #4129, #4132, #4134) - `WithRouteTag` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` adds HTTP route attribute to metrics. (#615) - Add `WithSpanOptions` option in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#3768) +- Add testing support for Go 1.21. (#4233) ### Fixed diff --git a/README.md b/README.md index 2bdbdae6e25..1e802141abf 100644 --- a/README.md +++ b/README.md @@ -48,14 +48,19 @@ This project is tested on the following systems. | OS | Go Version | Architecture | | ------- | ---------- | ------------ | +| Ubuntu | 1.21 | amd64 | | Ubuntu | 1.20 | amd64 | | Ubuntu | 1.19 | amd64 | +| Ubuntu | 1.21 | 386 | | Ubuntu | 1.20 | 386 | | Ubuntu | 1.19 | 386 | +| MacOS | 1.21 | amd64 | | MacOS | 1.20 | amd64 | | MacOS | 1.19 | amd64 | +| Windows | 1.21 | amd64 | | Windows | 1.20 | amd64 | | Windows | 1.19 | amd64 | +| Windows | 1.21 | 386 | | Windows | 1.20 | 386 | | Windows | 1.19 | 386 | diff --git a/samplers/aws/xray/remote_sampler_config.go b/samplers/aws/xray/remote_sampler_config.go index b12a96fb6cd..6305cf8f920 100644 --- a/samplers/aws/xray/remote_sampler_config.go +++ b/samplers/aws/xray/remote_sampler_config.go @@ -74,6 +74,8 @@ func WithLogger(l logr.Logger) Option { }) } +var defaultLogger = stdr.NewWithOptions(log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile), stdr.Options{LogCaller: stdr.Error}) + func newConfig(opts ...Option) (*config, error) { defaultProxyEndpoint, err := url.Parse("http://127.0.0.1:2000") if err != nil { @@ -83,7 +85,7 @@ func newConfig(opts ...Option) (*config, error) { cfg := &config{ endpoint: *defaultProxyEndpoint, samplingRulesPollingInterval: defaultPollingInterval * time.Second, - logger: stdr.NewWithOptions(log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile), stdr.Options{LogCaller: stdr.Error}), + logger: defaultLogger, } for _, option := range opts { diff --git a/samplers/aws/xray/remote_sampler_config_test.go b/samplers/aws/xray/remote_sampler_config_test.go index 1c636806566..ce87eed4b9c 100644 --- a/samplers/aws/xray/remote_sampler_config_test.go +++ b/samplers/aws/xray/remote_sampler_config_test.go @@ -15,16 +15,13 @@ package xray import ( - "log" "net/url" - "os" "testing" "time" "github.com/stretchr/testify/require" "github.com/go-logr/logr" - "github.com/go-logr/stdr" "github.com/stretchr/testify/assert" ) @@ -51,7 +48,7 @@ func TestDefaultConfig(t *testing.T) { assert.Equal(t, cfg.samplingRulesPollingInterval, 300*time.Second) assert.Equal(t, cfg.endpoint, *endpoint) - assert.Equal(t, cfg.logger, stdr.NewWithOptions(log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile), stdr.Options{LogCaller: stdr.Error})) + assert.Equal(t, cfg.logger, defaultLogger) } // assert when some config is provided by user then other config will be picked up from default config. @@ -64,7 +61,7 @@ func TestPartialUserProvidedConfig(t *testing.T) { assert.Equal(t, cfg.samplingRulesPollingInterval, 500*time.Second) assert.Equal(t, cfg.endpoint, *endpoint) - assert.Equal(t, cfg.logger, stdr.NewWithOptions(log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile), stdr.Options{LogCaller: stdr.Error})) + assert.Equal(t, cfg.logger, defaultLogger) } // assert that valid endpoint would not result in an error.