Skip to content

Prevent map lookups in traceglobal probe when using Go >= 1.24 - #1573

Merged
MrAlias merged 5 commits into
open-telemetry:mainfrom
MrAlias:go-1.24-otel-global
Jan 10, 2025
Merged

Prevent map lookups in traceglobal probe when using Go >= 1.24#1573
MrAlias merged 5 commits into
open-telemetry:mainfrom
MrAlias:go-1.24-otel-global

Conversation

@MrAlias

@MrAlias MrAlias commented Jan 9, 2025

Copy link
Copy Markdown
Contributor

Part of #1318

The traceglobal probe looks up tracers in a map. The current implementation will break for Go >= 1.24 where the map implementation will change. This adds a package constraint to ensure that probe is not loaded in that situation and documents this in COMPATIBILITY.md.

This was tested manually by setting the package constraint to Go >= 1.19 and building/running the rolldice example with appropriate versions. The appropriate warnings were logged.

go-auto-1   | {"time":"2025-01-09T22:20:37.982853153Z","level":"INFO","source":{"function":"main.main","file":"/app/cli/main.go","line":103},"msg":"building OpenTelemetry Go instrumentation ...","globalImpl":false,"version":{"Release":"v0.19.0-alpha","Revision":"060b385bd6615d86178576fcc00ce8a42fd1f173-dirty","Go":{"Version":"go1.23.4","OS":"linux","Arch":"amd64"}}}
go-auto-1   | {"time":"2025-01-09T22:20:40.003146178Z","level":"INFO","source":{"function":"go.opentelemetry.io/auto/internal/pkg/process.(*Analyzer).DiscoverProcessID","file":"/app/internal/pkg/process/discover.go","line":64},"msg":"found process","pid":813756}
go-auto-1   | {"time":"2025-01-09T22:20:40.014164784Z","level":"INFO","source":{"function":"go.opentelemetry.io/auto/internal/pkg/process.remoteAllocate.func1","file":"/app/internal/pkg/process/allocate.go","line":70},"msg":"Detaching from process","pid":813756}
go-auto-1   | {"time":"2025-01-09T22:20:40.014328357Z","level":"INFO","source":{"function":"go.opentelemetry.io/auto.NewInstrumentation","file":"/app/instrumentation.go","line":113},"msg":"target process analysis completed","pid":813756,"go_version":"1.22.10","dependencies":{"github.com/go-logr/logr":"1.4.2","github.com/go-logr/stdr":"1.2.2","go.opentelemetry.io/otel":"1.31.0","go.opentelemetry.io/otel/metric":"1.31.0","go.opentelemetry.io/otel/trace":"1.31.0","std":"1.22.10"},"total_functions_found":4}
go-auto-1   | {"time":"2025-01-09T22:20:40.020969534Z","level":"INFO","source":{"function":"go.opentelemetry.io/auto/internal/pkg/instrumentation.(*Manager).loadProbes","file":"/app/internal/pkg/instrumentation/manager.go","line":374},"msg":"loading probe","name":{"SpanKind":2,"InstrumentedPkg":"net/http"}}
go-auto-1   | {"time":"2025-01-09T22:20:40.411866414Z","level":"INFO","source":{"function":"go.opentelemetry.io/auto/internal/pkg/instrumentation.(*Manager).loadProbes","file":"/app/internal/pkg/instrumentation/manager.go","line":374},"msg":"loading probe","name":{"SpanKind":3,"InstrumentedPkg":"go.opentelemetry.io/otel/internal/global"}}
go-auto-1   | {"time":"2025-01-09T22:20:40.800743683Z","level":"WARN","source":{"function":"go.opentelemetry.io/auto/internal/pkg/instrumentation/probe.(*Base[...]).loadUprobes","file":"/app/internal/pkg/instrumentation/probe/probe.go","line":187},"msg":"package constraint not meet, skipping uprobe","probe":{"SpanKind":3,"InstrumentedPkg":"go.opentelemetry.io/otel/internal/global"},"symbol":"go.opentelemetry.io/otel/internal/global.(*tracer).Start","package":"std","constraint":"< 1.19.0"}
go-auto-1   | {"time":"2025-01-09T22:20:40.800781614Z","level":"WARN","source":{"function":"go.opentelemetry.io/auto/internal/pkg/instrumentation/probe.(*Base[...]).loadUprobes","file":"/app/internal/pkg/instrumentation/probe/probe.go","line":187},"msg":"package constraint not meet, skipping uprobe","probe":{"SpanKind":3,"InstrumentedPkg":"go.opentelemetry.io/otel/internal/global"},"symbol":"go.opentelemetry.io/otel/internal/global.(*nonRecordingSpan).End","package":"std","constraint":"< 1.19.0"}
go-auto-1   | {"time":"2025-01-09T22:20:40.80079266Z","level":"WARN","source":{"function":"go.opentelemetry.io/auto/internal/pkg/instrumentation/probe.(*Base[...]).loadUprobes","file":"/app/internal/pkg/instrumentation/probe/probe.go","line":187},"msg":"package constraint not meet, skipping uprobe","probe":{"SpanKind":3,"InstrumentedPkg":"go.opentelemetry.io/otel/internal/global"},"symbol":"go.opentelemetry.io/otel/internal/global.(*nonRecordingSpan).SetAttributes","package":"std","constraint":"< 1.19.0"}
go-auto-1   | {"time":"2025-01-09T22:20:40.800804997Z","level":"WARN","source":{"function":"go.opentelemetry.io/auto/internal/pkg/instrumentation/probe.(*Base[...]).loadUprobes","file":"/app/internal/pkg/instrumentation/probe/probe.go","line":187},"msg":"package constraint not meet, skipping uprobe","probe":{"SpanKind":3,"InstrumentedPkg":"go.opentelemetry.io/otel/internal/global"},"symbol":"go.opentelemetry.io/otel/internal/global.(*nonRecordingSpan).SetStatus","package":"std","constraint":"< 1.19.0"}
go-auto-1   | {"time":"2025-01-09T22:20:40.800819684Z","level":"WARN","source":{"function":"go.opentelemetry.io/auto/internal/pkg/instrumentation/probe.(*Base[...]).loadUprobes","file":"/app/internal/pkg/instrumentation/probe/probe.go","line":187},"msg":"package constraint not meet, skipping uprobe","probe":{"SpanKind":3,"InstrumentedPkg":"go.opentelemetry.io/otel/internal/global"},"symbol":"go.opentelemetry.io/otel/internal/global.(*nonRecordingSpan).SetName","package":"std","constraint":"< 1.19.0"}

Then the cut-off was reverted to 1.24 and the warnings were verified to no longer be logged.

Do no load the traceglobal direct global API instrumentation if the Go
version being used means swiss maps back the Go map implementation. The
probe does not handle this implementation but requires map parsing.
@MrAlias
MrAlias marked this pull request as ready for review January 9, 2025 22:32
@MrAlias
MrAlias requested a review from a team as a code owner January 9, 2025 22:32
@MrAlias
MrAlias merged commit 70a9938 into open-telemetry:main Jan 10, 2025
@MrAlias
MrAlias deleted the go-1.24-otel-global branch January 10, 2025 17:20
@MrAlias MrAlias added this to the v0.20.0-alpha milestone Jan 15, 2025
@MrAlias MrAlias mentioned this pull request Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants