alibaba / opentelemetry-go-auto-instrumentation

OpenTelemetry Compile-Time Instrumentation for Golang
Apache License 2.0
252 stars 35 forks source link

otel always intervenes even if I didn't add the otel prefix to the command #217

Closed cr7258 closed 4 days ago

cr7258 commented 1 week ago

Describe the bug

I have a simple go file.

package main

import (
    "fmt"
)

func main() {
    fmt.Println("xxx")
}

When I ran the go run command to run the program, it printed a single line as expected.

go run main.go

# output
xxx

However, after I run the otel go build command, the go binary seems to be hacked. Even if I just want to simply run the program, otel will also intervene.

go run main.go
# runtime
[instrument] 2024/11/22 20:09:18 Apply bundle {"PackageName":"runtime","ImportPath":"runtime","FileRules":[{"Path":".otel-build/preprocess/rule_cache/rules/runtime","ImportPath":"runtime","FileName":".otel-build/preprocess/rule_cache/rules/runtime/runtime_linker.go"}],"File2FuncRules":{"/Users/I576375/.version-fox/temp/1732204800-65677/golang/src/runtime/proc.go":{"newproc1,":[{"ImportPath":"runtime","Function":"newproc1","UseRaw":true,"OnEnter":"defer func(){ retVal0.otel_trace_context = contextPropagate(callergp.otel_trace_context); retVal0.otel_baggage_container = contextPropagate(callergp.otel_baggage_container); }()"}]}},"File2StructRules":{"/Users/I576375/.version-fox/temp/1732204800-65677/golang/src/runtime/runtime2.go":{"g":[{"ImportPath":"runtime","StructType":"g","FieldName":"otel_baggage_container","FieldType":"interface{}"},{"ImportPath":"runtime","StructType":"g","FieldName":"otel_trace_context","FieldType":"interface{}"}]}}}
[instrument] 2024/11/22 20:09:18 Apply file rule {"Path":".otel-build/preprocess/rule_cache/rules/runtime","ImportPath":"runtime","FileName":".otel-build/preprocess/rule_cache/rules/runtime/runtime_linker.go"}
[instrument] 2024/11/22 20:09:18 Apply struct rule {"ImportPath":"runtime","StructType":"g","FieldName":"otel_baggage_container","FieldType":"interface{}"}
[instrument] 2024/11/22 20:09:18 Apply struct rule {"ImportPath":"runtime","StructType":"g","FieldName":"otel_trace_context","FieldType":"interface{}"}
[instrument] 2024/11/22 20:09:18 Apply func rule {"ImportPath":"runtime","Function":"newproc1","UseRaw":true,"OnEnter":"defer func(){ retVal0.otel_trace_context = contextPropagate(callergp.otel_trace_context); retVal0.otel_baggage_container = contextPropagate(callergp.otel_baggage_container); }()"}
[instrument] 2024/11/22 20:09:19 RunCmd: runtime ([/Users/I576375/.version-fox/temp/1732204800-65677/golang/pkg/tool/darwin_arm64/compile -o $WORK/b010/_pkg_.a -trimpath $WORK/b010=> -p runtime -std -buildid ySHRjpn0An9NK1WOmfk6/ySHRjpn0An9NK1WOmfk6 -goversion go1.22.1 -symabis $WORK/b010/symabis -c=4 -shared -nolocalimports -importcfg $WORK/b010/importcfg -pack -asmhdr $WORK/b010/go_asm.h ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/alg.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/arena.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/asan0.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/atomic_pointer.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/cgo.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/cgocall.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/cgocallback.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/cgocheck.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/chan.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/checkptr.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/compiler.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/complex.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/coro.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/covercounter.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/covermeta.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/cpuflags.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/cpuflags_arm64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/cpuprof.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/create_file_unix.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/debug.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/debugcall.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/debuglog.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/debuglog_off.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/defs_darwin_arm64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/env_posix.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/error.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/exithook.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/extern.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/fastlog2.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/fastlog2table.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/fds_unix.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/float.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/hash64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/heapdump.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/histogram.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/iface.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/lfstack.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/lock_sema.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/lockrank.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/lockrank_off.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/malloc.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/map.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/map_fast32.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/map_fast64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/map_faststr.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mbarrier.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mbitmap.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mbitmap_allocheaders.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mcache.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mcentral.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mcheckmark.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mem.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mem_darwin.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/metrics.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mfinal.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mfixalloc.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mgc.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mgclimit.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mgcmark.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mgcpacer.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mgcscavenge.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mgcstack.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mgcsweep.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mgcwork.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mheap.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/minmax.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mpagealloc.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mpagealloc_64bit.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mpagecache.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mpallocbits.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mprof.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mranges.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/msan0.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/msize_allocheaders.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mspanset.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mstats.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/mwbbuf.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/nbpipe_pipe.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/netpoll.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/netpoll_kqueue.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/nonwindows_stub.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/os_darwin.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/os_darwin_arm64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/os_nonopenbsd.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/os_unix.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/os_unix_nonlinux.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/pagetrace_off.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/panic.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/pinner.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/plugin.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/preempt.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/preempt_nonwindows.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/print.go $WORK/b010/proc.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/profbuf.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/proflabel.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/race0.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/rand.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/rdebug.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/retry.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/runtime.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/runtime1.go $WORK/b010/runtime2.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/runtime_boring.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/rwmutex.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/security_issetugid.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/security_unix.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/select.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/sema.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/signal_arm64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/signal_darwin.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/signal_darwin_arm64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/signal_unix.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/sigqueue.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/sizeclasses.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/slice.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/softfloat64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/stack.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/stkframe.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/string.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/stubs.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/stubs_arm64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/stubs_nonlinux.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/symtab.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/symtabinl.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/sys_arm64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/sys_darwin.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/sys_darwin_arm64.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/sys_libc.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/sys_nonppc64x.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/tagptr.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/tagptr_64bit.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/test_stubs.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/time.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/time_nofake.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/timestub.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/tls_stub.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2buf.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2cpu.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2event.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2map.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2region.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2runtime.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2stack.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2status.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2string.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/trace2time.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/traceback.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/type.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/typekind.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/unsafe.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/utf8.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/vdso_in_none.go ../../../../.version-fox/temp/1732204800-65677/golang/src/runtime/write_err.go $WORK/b010/otel_inst_file_runtime_linker.go $WORK/b010/otel_api.go $WORK/b010/otel_trampoline.go])
xxx

Steps to reproduce

Run otel go build command first, then run go build command.

Expected behavior

otel shouldn't intervene when I didn't add the otel prefix to the command.

Actual behavior

otel always intervenes even if I didn't add the otel prefix to the command.

opentelemetry-go-auto-instrumentation version

otel version 1.0.0_94b8b9f (I build it from the latest main branch)

Environment

Go: go version go1.22.1 darwin/arm64 OS: MacOS 15.1

Additional context

No response

123liuziming commented 1 week ago

https://github.com/alibaba/opentelemetry-go-auto-instrumentation/issues/67 use go clean --cache to get rid of this. @y1yang0 https://github.com/alibaba/opentelemetry-go-auto-instrumentation/pull/78 This PR doesn't seem to be working, should we point it out in document?

123liuziming commented 1 week ago

https://github.com/alibaba/opentelemetry-go-auto-instrumentation/issues/203, we will point it out in document

y1yang0 commented 4 days ago

67 use go clean --cache to get rid of this. @y1yang0 #78 This PR doesn't seem to be working, should we point it out in document?

I will document it and add it back. It was removed because its inclusion would cause test problems. This time, I will thoroughly analyze these problems .