odigos-io / opentelemetry-go-instrumentation

OpenTelemetry auto-instrumentation for Go applications
Apache License 2.0
292 stars 44 forks source link

Unable to instrument go binary file which doesn't contain ".gosymtab" section #41

Open gongzh opened 2 years ago

gongzh commented 2 years ago

Expected Behavior

When a go binary file doesn't contain ".gosymtab" section, it should be able to instrument it.

Actual Behavior

Analyze process stops when it can't find ".gosymtab" section in target go binary file.

Steps to Reproduce the Problem

  1. ./launch goapp (launch binary copied from image keyval/launcher:v0.1)
  2. start instrumentation:
    OTEL_SERVICE_NAME=goapp  OTEL_TARGET_EXE=/goapp OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 /kv-go-instrumentation
  3. kv-go-instrumentation logs error and exits, error message are as below:
    {"level":"info","ts":1667322994.3850787,"caller":"cli/main.go:22","msg":"starting Go OpenTelemetry Agent ..."}
    {"level":"info","ts":1667322994.385147,"caller":"opentelemetry/controller.go:92","msg":"Establishing connection to OpenTelemetry collector ..."}
    {"level":"info","ts":1667322996.387433,"caller":"process/discover.go:42","msg":"found process","pid":19}
    {"level":"info","ts":1667322996.3889744,"caller":"process/analyze.go:73","msg":"found addr of keyval map","addr":140331000791040}
    {"level":"error","ts":1667322996.3974175,"caller":"cli/main.go:61","msg":"error while analyzing target process","error":".gosymtab section not found in target binary, make sure this is a Go application","stacktrace":"main.main\n\t/app/cli/main.go:61\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:250"}

The corresponding source code is from: https://github.com/keyval-dev/opentelemetry-go-instrumentation/blob/master/pkg/process/analyze.go line 117 to 120:

    sec := elfF.Section(".gosymtab")
    if sec == nil {
        return nil, fmt.Errorf("%s section not found in target binary, make sure this is a Go application", ".gosymtab")
    }