Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a new Span with a nil context causes a panic #3109

Closed
wildefires opened this issue Aug 25, 2022 · 0 comments · Fixed by #3110
Closed

Creating a new Span with a nil context causes a panic #3109

wildefires opened this issue Aug 25, 2022 · 0 comments · Fixed by #3110
Labels
bug Something isn't working

Comments

@wildefires
Copy link
Contributor

wildefires commented Aug 25, 2022

Description

Creating a new Span with a nil context causes a panic
Example https://go.dev/play/p/SXEK1EX_GzQ

Stack trace:

goroutine 1 [running]:
context.WithValue({0x0?, 0x0?}, {0x58aac0?, 0x6151e0?}, {0x5b9a20?, 0xc0002d4600?})
	/usr/local/go-faketime/src/context/context.go:525 +0x178
go.opentelemetry.io/otel/trace.ContextWithSpan(...)
	/tmp/gopath1305294289/pkg/mod/go.opentelemetry.io/otel/trace@v1.9.0/context.go:25
go.opentelemetry.io/otel/sdk/trace.(*tracer).Start(0xc00001e8c0?, {0x0?, 0x0?}, {0x5bf3e3?, 0x5?}, {0x0?, 0x60?, 0x726800?})
	/tmp/gopath1305294289/pkg/mod/go.opentelemetry.io/otel/sdk@v1.9.0/trace/tracer.go:58 +0x28c
main.main()
	/tmp/sandbox3842089424/prog.go:35 +0x264

IMO Otel should guard for this and if it's nil fill in a context.Background(). PR to do that: #3110

Environment

  • OS: Linux
  • Architecture: x64
  • Go Version: 1.19
  • opentelemetry-go version: 1.9.0 (based on panic stack trace)

Steps To Reproduce

  1. Provide a nil context to Start() (see Go Playground link in description)

Expected behavior

Typical Otel behavior seems to either No-op or use reasonable defaults. While this panic isn't coming from the Otel lib, but rather an std lib, I'd still expect the sdk to - at worst - provide a NoOp span based on similar behavior in other parts

@wildefires wildefires added the bug Something isn't working label Aug 25, 2022
@MrAlias MrAlias added this to the Release v1.10.0 milestone Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants