The incorrect initialization order of hooks led to them not being called correctly.
The key issue is that even if we add import otel_rules at the beginning of main.go to initialize the hook, we cannot ensure that it initializes before other packages. This is due to the lack of such guarantees in both the language specification and the compiler implementation. We need to have our hook setup in advance. One simple workaround is to find all the files in the user's project that contain init and add import otel_rules within them. This way, otel_rules becomes a dependency for all related packages, ensuring it is executed first. However, this approach is not elegant and feels rather stupid. We are considering a more clever solution using go:linkname.
The incorrect initialization order of hooks led to them not being called correctly.
The key issue is that even if we add
import otel_rules
at the beginning ofmain.go
to initialize the hook, we cannot ensure that it initializes before other packages. This is due to the lack of such guarantees in both the language specification and the compiler implementation. We need to have our hook setup in advance. One simple workaround is to find all the files in the user's project that containinit
and addimport otel_rules
within them. This way,otel_rules
becomes a dependency for all related packages, ensuring it is executed first. However, this approach is not elegant and feels rather stupid. We are considering a more clever solution usinggo:linkname
.