1 Star 0 Fork 0

Alibaba/opentelemetry-go-auto-instrumentation

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
how-to-debug.md 3.10 KB
一键复制 编辑 原始数据 按行查看 历史
Liu Ziming 提交于 3个月前 . support nacos (#266)

How to debug instrumented program

opentelemetry-go-auto-instrumentation provides some convenient ways for users to debug the instrumented program.

1. Perform instrumentation with -debug options

$ ./otel set -debug

When using the -debug compilation option, the tool will compile an unoptimized binary while retaining all generated temporary files, such as otel_rules. You can review them to understand what kind of code the tool is injecting.

2. Check .otel-build directory

Even without using the -debug option, the tool will retain the necessary modified file copies in .otel-build, and its structure is as follows:

.otel-build
├── instrument
│   ├── baggage
│   │   ├── otel_inst_file_context.go
│   │   ├── otel_inst_file_ot_baggage_linker.go
│   │   └── otel_inst_file_ot_baggage_util.go
│   ├── grpc
│   │   ├── clientconn.go
│   │   ├── otel_trampoline.go
│   │   └── server.go
│   ├── http
│   │   ├── otel_trampoline.go
│   │   ├── roundtrip.go
│   │   └── server.go
│   ├── log
│   │   ├── log.go
│   │   └── otel_trampoline.go
│   ├── otel
│   │   └── otel_inst_file_trace.go
│   ├── runtime
│   │   ├── otel_inst_file_runtime_linker.go
│   │   ├── otel_trampoline.go
│   │   ├── proc.go
│   │   └── runtime2.go
│   ├── slog
│   │   ├── logger.go
│   │   └── otel_trampoline.go
│   └── trace
│       ├── otel_inst_file_ot_trace_context.go
│       ├── otel_inst_file_ot_trace_context_linker.go
│       ├── otel_inst_file_span.go
│       └── otel_inst_file_tracer.go
└── preprocess
    ├── backups
    │   ├── app2.go.bk
    │   ├── go.mod.bk
    │   └── go.sum.bk
    ├── dry_run.log
    ├── otel_rules
    │   ├── grpc72047
    │   │   ├── ...
    │   ├── http02075
    │   │   ├── client_setup.go
    │   │   ├── ...
    │   ├── log09344
    │   │   └── setup.go
    │   ├── otel_setup_inst.go
    │   ├── otel_setup_sdk.go
    │   └── slog54146
    │       └── setup.go
    ├── otel_user
    │   ├── app2.go
    │   ├── go.mod
    │   └── go.sum
    ├── rule_bundle.json
    └── rule_cache
        └── ...

The terms "preprocess" and "instrument" represent files generated during two different stages. Please refer to this document for information about the two stages. For example, instrument/grpc/clientconn.go indicates the clientconn.go file after code injection. rule_bundle.json contains the matched rules, and nearly all important files relevant to debugging will be retained in this directory.

3. Use delve to debug binary

No optimization will be taken with the -debug option during the hybrid compilation. Users can use delve to debug the binary file easily.

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/alibaba/opentelemetry-go-auto-instrumentation.git
git@gitee.com:alibaba/opentelemetry-go-auto-instrumentation.git
alibaba
opentelemetry-go-auto-instrumentation
opentelemetry-go-auto-instrumentation
main

搜索帮助

371d5123 14472233 46e8bd33 14472233