diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d682bd59b88..c6fe0b76e11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -167,7 +167,7 @@ jobs: compatibility-test: strategy: matrix: - go-version: ["1.26.0", "1.25.0", "1.24.0"] + go-version: ["1.26.0", "1.25.0"] platform: - os: ubuntu-latest arch: "386" diff --git a/CHANGELOG.md b/CHANGELOG.md index b5568ffb5e1..7f93ff5cd1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Removed + +- Drop support for [Go 1.24]. (#7984) + diff --git a/README.md b/README.md index 6b1e170c4be..16a72004c08 100644 --- a/README.md +++ b/README.md @@ -55,25 +55,18 @@ Currently, this project supports the following environments. |----------|------------|--------------| | Ubuntu | 1.26 | amd64 | | Ubuntu | 1.25 | amd64 | -| Ubuntu | 1.24 | amd64 | | Ubuntu | 1.26 | 386 | | Ubuntu | 1.25 | 386 | -| Ubuntu | 1.24 | 386 | | Ubuntu | 1.26 | arm64 | | Ubuntu | 1.25 | arm64 | -| Ubuntu | 1.24 | arm64 | | macOS | 1.26 | amd64 | | macOS | 1.25 | amd64 | -| macOS | 1.24 | amd64 | | macOS | 1.26 | arm64 | | macOS | 1.25 | arm64 | -| macOS | 1.24 | arm64 | | Windows | 1.26 | amd64 | | Windows | 1.25 | amd64 | -| Windows | 1.24 | amd64 | | Windows | 1.26 | 386 | | Windows | 1.25 | 386 | -| Windows | 1.24 | 386 | While this project should work for other systems, no compatibility guarantees are made for those systems currently. diff --git a/bridge/opencensus/go.mod b/bridge/opencensus/go.mod index 197713d111a..35fefdb73aa 100644 --- a/bridge/opencensus/go.mod +++ b/bridge/opencensus/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/bridge/opencensus -go 1.24.0 +go 1.25.0 require ( github.com/stretchr/testify v1.11.1 diff --git a/bridge/opencensus/test/go.mod b/bridge/opencensus/test/go.mod index 6df731d23e0..0c617fcf9b5 100644 --- a/bridge/opencensus/test/go.mod +++ b/bridge/opencensus/test/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/bridge/opencensus/test -go 1.24.0 +go 1.25.0 require ( go.opencensus.io v0.24.0 diff --git a/bridge/opentracing/go.mod b/bridge/opentracing/go.mod index 62b2c37c26d..f55a0621b2b 100644 --- a/bridge/opentracing/go.mod +++ b/bridge/opentracing/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/bridge/opentracing -go 1.24.0 +go 1.25.0 replace go.opentelemetry.io/otel => ../.. diff --git a/exporters/otlp/otlplog/otlploggrpc/exporter_test.go b/exporters/otlp/otlplog/otlploggrpc/exporter_test.go index 86840b69e59..5c59af73dc9 100644 --- a/exporters/otlp/otlplog/otlploggrpc/exporter_test.go +++ b/exporters/otlp/otlplog/otlploggrpc/exporter_test.go @@ -126,10 +126,7 @@ func TestExporterConcurrentSafe(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) runs := new(uint64) for range goroutines { - wg.Add(1) - go func() { - defer wg.Done() - + wg.Go(func() { r := make([]sdklog.Record, 1) for { select { @@ -141,7 +138,7 @@ func TestExporterConcurrentSafe(t *testing.T) { atomic.AddUint64(runs, 1) } } - }() + }) } for atomic.LoadUint64(runs) == 0 { diff --git a/exporters/otlp/otlplog/otlploggrpc/go.mod b/exporters/otlp/otlplog/otlploggrpc/go.mod index a5293af3d89..f2e43ea70ac 100644 --- a/exporters/otlp/otlplog/otlploggrpc/go.mod +++ b/exporters/otlp/otlplog/otlploggrpc/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc -go 1.24.0 +go 1.25.0 // Contains broken dependency on go.opentelemetry.io/otel/sdk/log/logtest. retract v0.12.0 diff --git a/exporters/otlp/otlplog/otlploghttp/exporter_test.go b/exporters/otlp/otlplog/otlploghttp/exporter_test.go index 02491a03e27..84f81475367 100644 --- a/exporters/otlp/otlplog/otlploghttp/exporter_test.go +++ b/exporters/otlp/otlplog/otlploghttp/exporter_test.go @@ -94,10 +94,7 @@ func TestExporterConcurrentSafe(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) runs := new(uint64) for range goroutines { - wg.Add(1) - go func() { - defer wg.Done() - + wg.Go(func() { r := make([]log.Record, 1) for { select { @@ -109,7 +106,7 @@ func TestExporterConcurrentSafe(t *testing.T) { atomic.AddUint64(runs, 1) } } - }() + }) } for atomic.LoadUint64(runs) == 0 { diff --git a/exporters/otlp/otlplog/otlploghttp/go.mod b/exporters/otlp/otlplog/otlploghttp/go.mod index 95504677c0f..b5c2e262c42 100644 --- a/exporters/otlp/otlplog/otlploghttp/go.mod +++ b/exporters/otlp/otlplog/otlploghttp/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp -go 1.24.0 +go 1.25.0 // Contains broken dependency on go.opentelemetry.io/otel/sdk/log/logtest. retract v0.12.0 diff --git a/exporters/otlp/otlpmetric/otlpmetricgrpc/exporter_test.go b/exporters/otlp/otlpmetric/otlpmetricgrpc/exporter_test.go index eaa40412b60..b39ec761d8f 100644 --- a/exporters/otlp/otlpmetric/otlpmetricgrpc/exporter_test.go +++ b/exporters/otlp/otlpmetric/otlpmetricgrpc/exporter_test.go @@ -84,14 +84,12 @@ func TestExporterDoesNotBlockTemporalityAndAggregation(t *testing.T) { require.NoError(t, err) var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { rm := new(metricdata.ResourceMetrics) t.Log("starting export") require.NoError(t, exp.Export(ctx, rm)) t.Log("export complete") - }() + }) assert.Eventually(t, func() bool { const inst = metric.InstrumentKindCounter diff --git a/exporters/otlp/otlpmetric/otlpmetricgrpc/go.mod b/exporters/otlp/otlpmetric/otlpmetricgrpc/go.mod index 98181895eb7..97e8382d3c7 100644 --- a/exporters/otlp/otlpmetric/otlpmetricgrpc/go.mod +++ b/exporters/otlp/otlpmetric/otlpmetricgrpc/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc -go 1.24.0 +go 1.25.0 retract v0.32.2 // Contains unresolvable dependencies. diff --git a/exporters/otlp/otlpmetric/otlpmetrichttp/exporter_test.go b/exporters/otlp/otlpmetric/otlpmetrichttp/exporter_test.go index 08195560cf6..e9f44ba501e 100644 --- a/exporters/otlp/otlpmetric/otlpmetrichttp/exporter_test.go +++ b/exporters/otlp/otlpmetric/otlpmetrichttp/exporter_test.go @@ -84,14 +84,12 @@ func TestExporterDoesNotBlockTemporalityAndAggregation(t *testing.T) { require.NoError(t, err) var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { rm := new(metricdata.ResourceMetrics) t.Log("starting export") require.NoError(t, exp.Export(ctx, rm)) t.Log("export complete") - }() + }) assert.Eventually(t, func() bool { const inst = metric.InstrumentKindCounter diff --git a/exporters/otlp/otlpmetric/otlpmetrichttp/go.mod b/exporters/otlp/otlpmetric/otlpmetrichttp/go.mod index e76324d15c4..bdf64b7d17c 100644 --- a/exporters/otlp/otlpmetric/otlpmetrichttp/go.mod +++ b/exporters/otlp/otlpmetric/otlpmetrichttp/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp -go 1.24.0 +go 1.25.0 retract v0.32.2 // Contains unresolvable dependencies. diff --git a/exporters/otlp/otlptrace/go.mod b/exporters/otlp/otlptrace/go.mod index f52db56b61b..84681eb527a 100644 --- a/exporters/otlp/otlptrace/go.mod +++ b/exporters/otlp/otlptrace/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/otlp/otlptrace -go 1.24.0 +go 1.25.0 require ( github.com/google/go-cmp v0.7.0 diff --git a/exporters/otlp/otlptrace/otlptracegrpc/go.mod b/exporters/otlp/otlptrace/otlptracegrpc/go.mod index 921d8362c92..3975ff39fb6 100644 --- a/exporters/otlp/otlptrace/otlptracegrpc/go.mod +++ b/exporters/otlp/otlptrace/otlptracegrpc/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc -go 1.24.0 +go 1.25.0 require ( github.com/cenkalti/backoff/v5 v5.0.3 diff --git a/exporters/otlp/otlptrace/otlptracehttp/go.mod b/exporters/otlp/otlptrace/otlptracehttp/go.mod index d1b84846933..2be68aaeb1b 100644 --- a/exporters/otlp/otlptrace/otlptracehttp/go.mod +++ b/exporters/otlp/otlptrace/otlptracehttp/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp -go 1.24.0 +go 1.25.0 require ( github.com/cenkalti/backoff/v5 v5.0.3 diff --git a/exporters/prometheus/exporter_test.go b/exporters/prometheus/exporter_test.go index eda709be59f..326f481d3b5 100644 --- a/exporters/prometheus/exporter_test.go +++ b/exporters/prometheus/exporter_test.go @@ -1162,12 +1162,10 @@ func TestCollectorConcurrentSafe(t *testing.T) { var wg sync.WaitGroup concurrencyLevel := 10 for range concurrencyLevel { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _, err := registry.Gather() // this calls collector.Collect assert.NoError(t, err) - }() + }) } wg.Wait() diff --git a/exporters/prometheus/go.mod b/exporters/prometheus/go.mod index 5f28a3c90e0..6b5d4b1a69f 100644 --- a/exporters/prometheus/go.mod +++ b/exporters/prometheus/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/prometheus -go 1.24.0 +go 1.25.0 // v0.59.0 produces incorrect metric names when bracketed units are used. // https://github.com/open-telemetry/opentelemetry-go/issues/7039 diff --git a/exporters/stdout/stdoutlog/go.mod b/exporters/stdout/stdoutlog/go.mod index 3b682a2e6eb..513d27986cc 100644 --- a/exporters/stdout/stdoutlog/go.mod +++ b/exporters/stdout/stdoutlog/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/stdout/stdoutlog -go 1.24.0 +go 1.25.0 // Contains broken dependency on go.opentelemetry.io/otel/sdk/log/logtest. retract v0.12.0 diff --git a/exporters/stdout/stdoutmetric/go.mod b/exporters/stdout/stdoutmetric/go.mod index 100b29a12fa..abd4743036a 100644 --- a/exporters/stdout/stdoutmetric/go.mod +++ b/exporters/stdout/stdoutmetric/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/stdout/stdoutmetric -go 1.24.0 +go 1.25.0 require ( github.com/stretchr/testify v1.11.1 diff --git a/exporters/stdout/stdouttrace/go.mod b/exporters/stdout/stdouttrace/go.mod index 64cde8bb7df..5e87062ddda 100644 --- a/exporters/stdout/stdouttrace/go.mod +++ b/exporters/stdout/stdouttrace/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/exporters/stdout/stdouttrace -go 1.24.0 +go 1.25.0 replace ( go.opentelemetry.io/otel => ../../.. diff --git a/exporters/zipkin/go.mod b/exporters/zipkin/go.mod index 7c5b39013ff..b89dcc2b0fc 100644 --- a/exporters/zipkin/go.mod +++ b/exporters/zipkin/go.mod @@ -2,7 +2,7 @@ // See the blog post "Deprecating Zipkin Exporter": https://opentelemetry.io/blog/2025/deprecating-zipkin-exporters/ module go.opentelemetry.io/otel/exporters/zipkin -go 1.24.0 +go 1.25.0 require ( github.com/go-logr/logr v1.4.3 diff --git a/go.mod b/go.mod index 4591eac0690..a5db24f20b3 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel -go 1.24.0 +go 1.25.0 require ( github.com/cespare/xxhash/v2 v2.3.0 diff --git a/internal/global/internal_logging_test.go b/internal/global/internal_logging_test.go index 5937b0f3062..e94559ac124 100644 --- a/internal/global/internal_logging_test.go +++ b/internal/global/internal_logging_test.go @@ -19,16 +19,12 @@ import ( func TestLoggerConcurrentSafe(t *testing.T) { var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { SetLogger(stdr.New(log.New(io.Discard, "", 0))) - }() - wg.Add(1) - go func() { - defer wg.Done() + }) + wg.Go(func() { Info("") - }() + }) wg.Wait() ResetForTest(t) diff --git a/internal/tools/go.mod b/internal/tools/go.mod index ad3ba218f7e..0a1a0a57670 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/internal/tools -go 1.24.0 +go 1.25.0 require ( github.com/Masterminds/semver v1.5.0 diff --git a/log/go.mod b/log/go.mod index a111ec25d80..0b1477f7eab 100644 --- a/log/go.mod +++ b/log/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/log -go 1.24.0 +go 1.25.0 require ( github.com/go-logr/logr v1.4.3 diff --git a/log/logtest/go.mod b/log/logtest/go.mod index 9dad200ae74..c4a39a6ff6b 100644 --- a/log/logtest/go.mod +++ b/log/logtest/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/log/logtest -go 1.24.0 +go 1.25.0 require ( github.com/google/go-cmp v0.7.0 diff --git a/metric/go.mod b/metric/go.mod index 42b3e54a04e..28bf1c0b27c 100644 --- a/metric/go.mod +++ b/metric/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/metric -go 1.24.0 +go 1.25.0 require ( github.com/stretchr/testify v1.11.1 diff --git a/metric/instrument_test.go b/metric/instrument_test.go index f7fc295d65d..34e09383ebc 100644 --- a/metric/instrument_test.go +++ b/metric/instrument_test.go @@ -98,44 +98,32 @@ func TestWithAttributesConcurrentSafe(*testing.T) { } var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { opt := []AddOption{WithAttributes(attrs...)} _ = NewAddConfig(opt) - }() - wg.Add(1) - go func() { - defer wg.Done() + }) + wg.Go(func() { opt := []AddOption{WithAttributes(attrs...)} _ = NewAddConfig(opt) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { opt := []RecordOption{WithAttributes(attrs...)} _ = NewRecordConfig(opt) - }() - wg.Add(1) - go func() { - defer wg.Done() + }) + wg.Go(func() { opt := []RecordOption{WithAttributes(attrs...)} _ = NewRecordConfig(opt) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { opt := []ObserveOption{WithAttributes(attrs...)} _ = NewObserveConfig(opt) - }() - wg.Add(1) - go func() { - defer wg.Done() + }) + wg.Go(func() { opt := []ObserveOption{WithAttributes(attrs...)} _ = NewObserveConfig(opt) - }() + }) wg.Wait() } diff --git a/schema/go.mod b/schema/go.mod index 3d7c92447f1..77ade3f7c01 100644 --- a/schema/go.mod +++ b/schema/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/schema -go 1.24.0 +go 1.25.0 require ( github.com/Masterminds/semver/v3 v3.4.0 diff --git a/sdk/go.mod b/sdk/go.mod index ff57c91c58d..82bd2dfb062 100644 --- a/sdk/go.mod +++ b/sdk/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/sdk -go 1.24.0 +go 1.25.0 replace go.opentelemetry.io/otel => ../ diff --git a/sdk/log/batch_test.go b/sdk/log/batch_test.go index 2d41c733358..81636f0be56 100644 --- a/sdk/log/batch_test.go +++ b/sdk/log/batch_test.go @@ -498,9 +498,7 @@ func TestBatchProcessor(t *testing.T) { ctx, cancel := context.WithCancel(ctx) var wg sync.WaitGroup for range goRoutines - 1 { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for { select { case <-ctx.Done(): @@ -511,19 +509,17 @@ func TestBatchProcessor(t *testing.T) { _ = b.ForceFlush(ctx) } } - }() + }) } require.Eventually(t, func() bool { return e.ExportN() > 0 }, 2*time.Second, time.Microsecond, "export before shutdown") - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { assert.NoError(t, b.Shutdown(ctx)) cancel() - }() + }) wg.Wait() }) diff --git a/sdk/log/exporter_test.go b/sdk/log/exporter_test.go index cd6b00153a0..352c55b7b6a 100644 --- a/sdk/log/exporter_test.go +++ b/sdk/log/exporter_test.go @@ -219,15 +219,12 @@ func TestExportSync(t *testing.T) { done := exportSync(in, exp) var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - + wg.Go(func() { in <- exportData{ ctx: t.Context(), records: make([]Record, 1), } - }() + }) wg.Wait() close(in) @@ -339,9 +336,7 @@ func TestBufferExporter(t *testing.T) { stop := make(chan struct{}) var wg sync.WaitGroup for range goRoutines { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for { select { case <-stop: @@ -352,7 +347,7 @@ func TestBufferExporter(t *testing.T) { _ = e.ForceFlush(ctx) } } - }() + }) } assert.Eventually(t, func() bool { diff --git a/sdk/log/go.mod b/sdk/log/go.mod index 24828fd7ccf..0d001a257b0 100644 --- a/sdk/log/go.mod +++ b/sdk/log/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/sdk/log -go 1.24.0 +go 1.25.0 require ( github.com/go-logr/logr v1.4.3 diff --git a/sdk/log/logtest/go.mod b/sdk/log/logtest/go.mod index 07e2a7eea68..56123031c80 100644 --- a/sdk/log/logtest/go.mod +++ b/sdk/log/logtest/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/sdk/log/logtest -go 1.24.0 +go 1.25.0 require ( github.com/stretchr/testify v1.11.1 diff --git a/sdk/log/record_test.go b/sdk/log/record_test.go index ec3107c719d..464de692ff4 100644 --- a/sdk/log/record_test.go +++ b/sdk/log/record_test.go @@ -1521,10 +1521,7 @@ func TestRecordMethodsInputConcurrentSafe(t *testing.T) { var wg sync.WaitGroup for range 10 { - wg.Add(1) - go func() { - defer wg.Done() - + wg.Go(func() { r := &Record{ attributeValueLengthLimit: 10, attributeCountLimit: 4, @@ -1565,7 +1562,7 @@ func TestRecordMethodsInputConcurrentSafe(t *testing.T) { if !gotBody.Equal(wantBody) { t.Errorf("Body does not match.\ngot:\n%v\nwant:\n%v", gotBody, wantBody) } - }() + }) } wg.Wait() diff --git a/sdk/metric/exemplar/reservoir_test.go b/sdk/metric/exemplar/reservoir_test.go index 6d1f63c589d..b759a2f9cfd 100644 --- a/sdk/metric/exemplar/reservoir_test.go +++ b/sdk/metric/exemplar/reservoir_test.go @@ -188,12 +188,10 @@ func reservoirConcurrentSafeTest[N int64 | float64](f factory) func(*testing.T) } // Also test concurrent Collect calls - wg.Add(1) - go func() { + wg.Go(func() { var dest []Exemplar r.Collect(&dest) - wg.Done() - }() + }) wg.Wait() diff --git a/sdk/metric/exemplar_test.go b/sdk/metric/exemplar_test.go index 10aabac65a5..1a1159ad057 100644 --- a/sdk/metric/exemplar_test.go +++ b/sdk/metric/exemplar_test.go @@ -38,9 +38,7 @@ func TestFixedSizeExemplarConcurrentSafe(t *testing.T) { var wg sync.WaitGroup for range goRoutines { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for { select { case <-ctx.Done(): @@ -49,7 +47,7 @@ func TestFixedSizeExemplarConcurrentSafe(t *testing.T) { require.NotPanics(t, add) } } - }() + }) } const collections = 100 diff --git a/sdk/metric/go.mod b/sdk/metric/go.mod index 6d6f6faf5d4..49283c8ea1c 100644 --- a/sdk/metric/go.mod +++ b/sdk/metric/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/sdk/metric -go 1.24.0 +go 1.25.0 require ( github.com/go-logr/logr v1.4.3 diff --git a/sdk/metric/internal/aggregate/aggregate_test.go b/sdk/metric/internal/aggregate/aggregate_test.go index 7dbc7bd8193..291a156ebfd 100644 --- a/sdk/metric/internal/aggregate/aggregate_test.go +++ b/sdk/metric/internal/aggregate/aggregate_test.go @@ -161,15 +161,11 @@ func testAggergationConcurrentSafe[N int64 | float64]( {ctx, 3, bob}, {ctx, 6, bob}, } { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { meas(args.ctx, args.value, args.attr) - }() + }) } - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for range 2 { comp(got) // We do not check expected output for each step because @@ -177,7 +173,7 @@ func testAggergationConcurrentSafe[N int64 | float64]( // we validate that the output is a valid possible output. validate(t, *got) } - }() + }) wg.Wait() } } diff --git a/sdk/metric/internal/aggregate/atomic_test.go b/sdk/metric/internal/aggregate/atomic_test.go index 174ef764f21..a395bee4c4c 100644 --- a/sdk/metric/internal/aggregate/atomic_test.go +++ b/sdk/metric/internal/aggregate/atomic_test.go @@ -22,11 +22,9 @@ func TestAtomicSumAddFloatConcurrentSafe(t *testing.T) { 10.55, 42.4, } { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { aSum.add(in) - }() + }) } wg.Wait() assert.Equal(t, float64(55), math.Round(aSum.load())) @@ -42,11 +40,9 @@ func TestAtomicSumAddIntConcurrentSafe(t *testing.T) { 4, 5, } { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { aSum.add(in) - }() + }) } wg.Wait() assert.Equal(t, int64(15), aSum.load()) @@ -84,13 +80,11 @@ func TestHotColdWaitGroupConcurrentSafe(t *testing.T) { hcwg := &hotColdWaitGroup{} var data [2]uint64 for range 5 { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { hotIdx := hcwg.start() defer hcwg.done(hotIdx) atomic.AddUint64(&data[hotIdx], 1) - }() + }) } for range 2 { readIdx := hcwg.swapHotAndWait() @@ -129,22 +123,16 @@ func testAtomicNConcurrentSafe[N int64 | float64](t *testing.T) { var v atomicN[N] for range 2 { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { got := v.Load() assert.Equal(t, int64(0), int64(got)%6) - }() - wg.Add(1) - go func() { - defer wg.Done() + }) + wg.Go(func() { v.Store(12) - }() - wg.Add(1) - go func() { - defer wg.Done() + }) + wg.Go(func() { v.CompareAndSwap(0, 6) - }() + }) } wg.Wait() } @@ -202,11 +190,9 @@ func testAtomicMinMaxConcurrentSafe[N int64 | float64](t *testing.T) { assert.False(t, minMax.set.Load()) for _, i := range []float64{2, 4, 6, 8, -3, 0, 8, 0} { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { minMax.Update(N(i)) - }() + }) } wg.Wait() diff --git a/sdk/metric/internal/aggregate/filtered_reservoir_test.go b/sdk/metric/internal/aggregate/filtered_reservoir_test.go index 873fb2d7260..dda513473c6 100644 --- a/sdk/metric/internal/aggregate/filtered_reservoir_test.go +++ b/sdk/metric/internal/aggregate/filtered_reservoir_test.go @@ -37,11 +37,9 @@ func TestConcurrentSafeFilteredReservoir(t *testing.T) { reservoir := NewFilteredExemplarReservoir[int64](exemplar.AlwaysOnFilter, tc.reservoir) var wg sync.WaitGroup for range 5 { - wg.Add(1) - go func() { + wg.Go(func() { reservoir.Offer(t.Context(), 25, []attribute.KeyValue{}) - wg.Done() - }() + }) } into := []exemplar.Exemplar{} for range 2 { diff --git a/sdk/metric/pipeline_test.go b/sdk/metric/pipeline_test.go index ca0b34f826b..a91d8d06ecf 100644 --- a/sdk/metric/pipeline_test.go +++ b/sdk/metric/pipeline_test.go @@ -86,11 +86,9 @@ func TestPipelineConcurrentSafe(t *testing.T) { var wg sync.WaitGroup const threads = 2 for i := range threads { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = pipe.produce(ctx, &output) - }() + }) wg.Add(1) go func(n int) { @@ -100,15 +98,11 @@ func TestPipelineConcurrentSafe(t *testing.T) { pipe.addSync(instrumentation.Scope{}, sync) }(i) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { pipe.addMultiCallback(func(context.Context) error { return nil }) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { b := aggregate.Builder[int64]{ Temporality: metricdata.CumulativeTemporality, ReservoirFunc: nil, @@ -119,7 +113,7 @@ func TestPipelineConcurrentSafe(t *testing.T) { measures := []aggregate.Measure[int64]{} measures = append(measures, m) pipe.addInt64Measure(oID, measures) - }() + }) } wg.Wait() } @@ -549,35 +543,27 @@ func TestAddingAndObservingMeasureConcurrentSafe(t *testing.T) { require.NoError(t, err) wg := sync.WaitGroup{} - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _, err := m.Int64ObservableCounter("int64-observable-counter-2") require.NoError(t, err) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _, err := m.RegisterCallback( func(_ context.Context, o metric.Observer) error { o.ObserveInt64(oc1, 2) return nil }, oc1) require.NoError(t, err) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = mp.pipes[0].produce(t.Context(), &metricdata.ResourceMetrics{}) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = mp.pipes[1].produce(t.Context(), &metricdata.ResourceMetrics{}) - }() + }) wg.Wait() } diff --git a/sdk/metric/reader_test.go b/sdk/metric/reader_test.go index eee7d6c4736..72bbe19845e 100644 --- a/sdk/metric/reader_test.go +++ b/sdk/metric/reader_test.go @@ -147,37 +147,27 @@ func (ts *readerTestSuite) TestMethodConcurrentSafe() { var wg sync.WaitGroup const threads = 2 for range threads { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = ts.Reader.temporality(InstrumentKindCounter) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = ts.Reader.aggregation(InstrumentKindCounter) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = ts.Reader.Collect(ctx, &metricdata.ResourceMetrics{}) - }() + }) if f, ok := ts.Reader.(interface{ ForceFlush(context.Context) error }); ok { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = f.ForceFlush(ctx) - }() + }) } - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = ts.Reader.Shutdown(ctx) - }() + }) } wg.Wait() } diff --git a/sdk/resource/resource_test.go b/sdk/resource/resource_test.go index 37fe1fd157e..4f1a049a92a 100644 --- a/sdk/resource/resource_test.go +++ b/sdk/resource/resource_test.go @@ -825,13 +825,11 @@ func TestResourceConcurrentSafe(t *testing.T) { // because Resources are immutable. var wg sync.WaitGroup for range 2 { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { d := &fakeDetector{} _, err := resource.Detect(t.Context(), d) assert.NoError(t, err) - }() + }) } wg.Wait() } diff --git a/sdk/trace/batch_span_processor.go b/sdk/trace/batch_span_processor.go index 7d15cbb9c0f..c7c317fbcae 100644 --- a/sdk/trace/batch_span_processor.go +++ b/sdk/trace/batch_span_processor.go @@ -123,12 +123,10 @@ func NewBatchSpanProcessor(exporter SpanExporter, options ...BatchSpanProcessorO otel.Handle(err) } - bsp.stopWait.Add(1) - go func() { - defer bsp.stopWait.Done() + bsp.stopWait.Go(func() { bsp.processQueue() bsp.drainQueue() - }() + }) return bsp } diff --git a/sdk/trace/batch_span_processor_test.go b/sdk/trace/batch_span_processor_test.go index 724037d7de7..9adac094504 100644 --- a/sdk/trace/batch_span_processor_test.go +++ b/sdk/trace/batch_span_processor_test.go @@ -617,35 +617,25 @@ func TestBatchSpanProcessorConcurrentSafe(t *testing.T) { var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { generateSpan(t, tr, testOption{genNumSpans: 1}) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = bsp.ForceFlush(ctx) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = bsp.Shutdown(ctx) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = tp.ForceFlush(ctx) - }() + }) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = tp.Shutdown(ctx) - }() + }) wg.Wait() } diff --git a/trace/go.mod b/trace/go.mod index f1dede84a28..cfb96f177a2 100644 --- a/trace/go.mod +++ b/trace/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/trace -go 1.24.0 +go 1.25.0 replace go.opentelemetry.io/otel => ../ diff --git a/trace/internal/telemetry/test/go.mod b/trace/internal/telemetry/test/go.mod index 1cb700ebb77..3293b25b490 100644 --- a/trace/internal/telemetry/test/go.mod +++ b/trace/internal/telemetry/test/go.mod @@ -1,6 +1,6 @@ module go.opentelemetry.io/otel/trace/internal/telemetry/test -go 1.24.0 +go 1.25.0 require ( github.com/stretchr/testify v1.11.1