Skip to content

time: AfterFunc doesn't inherit parent goroutine labels #67708

@DmitriyMV

Description

@DmitriyMV

Go version

go version go1.22.3 or tip.

What did you do?

Run this code: https://go.dev/play/p/Yf7N3XhKsdF?v=gotip

What did you see happen?

goroutine profile: total 3
1 @ 0x42dcb1 0x4674fd 0x4b8a91 0x4b88c5 0x4b58eb 0x4ccf65 0x437d2b 0x46f581
# labels: {"myownlabel":"label"}
#	0x4b8a90	runtime/pprof.writeRuntimeProfile+0xb0	/usr/local/go-faketime/src/runtime/pprof/pprof.go:767
#	0x4b88c4	runtime/pprof.writeGoroutine+0x44	/usr/local/go-faketime/src/runtime/pprof/pprof.go:726
#	0x4b58ea	runtime/pprof.(*Profile).WriteTo+0x14a	/usr/local/go-faketime/src/runtime/pprof/pprof.go:368
#	0x4ccf64	main.main+0x1c4				/tmp/sandbox135271070/prog.go:24
#	0x437d2a	runtime.main+0x28a			/usr/local/go-faketime/src/runtime/proc.go:272

1 @ 0x46806e 0x46b4e5 0x4ccfbd 0x46f581
#	0x46b4e4	time.Sleep+0xe4		/usr/local/go-faketime/src/runtime/time.go:285
#	0x4ccfbc	main.main.func1+0x1c	/tmp/sandbox135271070/prog.go:18

1 @ 0x46806e 0x46b4e5 0x4ccffd 0x46f581
# labels: {"myownlabel":"label"}
#	0x46b4e4	time.Sleep+0xe4		/usr/local/go-faketime/src/runtime/time.go:285
#	0x4ccffc	main.main.func2+0x1c	/tmp/sandbox135271070/prog.go:20```

What did you expect to see?

goroutine profile: total 3
1 @ 0x42dcb1 0x4674fd 0x4b8a91 0x4b88c5 0x4b58eb 0x4ccf65 0x437d2b 0x46f581
# labels: {"myownlabel":"label"}
#	0x4b8a90	runtime/pprof.writeRuntimeProfile+0xb0	/usr/local/go-faketime/src/runtime/pprof/pprof.go:767
#	0x4b88c4	runtime/pprof.writeGoroutine+0x44	/usr/local/go-faketime/src/runtime/pprof/pprof.go:726
#	0x4b58ea	runtime/pprof.(*Profile).WriteTo+0x14a	/usr/local/go-faketime/src/runtime/pprof/pprof.go:368
#	0x4ccf64	main.main+0x1c4				/tmp/sandbox135271070/prog.go:24
#	0x437d2a	runtime.main+0x28a			/usr/local/go-faketime/src/runtime/proc.go:272

1 @ 0x46806e 0x46b4e5 0x4ccfbd 0x46f581
# labels: {"myownlabel":"label"}
#	0x46b4e4	time.Sleep+0xe4		/usr/local/go-faketime/src/runtime/time.go:285
#	0x4ccfbc	main.main.func1+0x1c	/tmp/sandbox135271070/prog.go:18

1 @ 0x46806e 0x46b4e5 0x4ccffd 0x46f581
# labels: {"myownlabel":"label"}
#	0x46b4e4	time.Sleep+0xe4		/usr/local/go-faketime/src/runtime/time.go:285
#	0x4ccffc	main.main.func2+0x1c	/tmp/sandbox135271070/prog.go:20

I think it's kinda confusing that this way you can bypass labels inheriting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions