otel-go
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenTelemetry in Go
Go 语言中的 OpenTelemetry
Entry point for OpenTelemetry mechanics in Go services. Load a reference below based on the
task; each reference is self-contained.
这是 Go 服务中 OpenTelemetry 相关机制的入口文档。根据任务需求加载下方的参考文档;每个参考文档都是独立完整的。
References
参考文档
| File | Use when |
|---|---|
| Configuring the SDK via |
| Looking up import paths, global API access, tracer/meter/logger usage, attributes, propagation, log bridges (zap, slog). |
| Picking or wiring contrib libraries (otelhttp, otelgrpc, database, AWS, message queues, propagators, resource detectors), and writing manual instrumentation that follows semconv. |
| Tuning sampling, batch processor, metric reader, exporter compression/retry, attribute allocation, log |
| Auditing existing code for deprecated calls, renamed semantic conventions, and removed APIs across recent SDK / contrib releases. |
| Zero-code, compile-time instrumentation with |
For upgrade reviews, always finish with a safe local verification path (,
, and ). Test exporter URL or retry changes against a disposable
local receiver, never a deployment endpoint.
go mod tidy -diffgo build ./...go test ./...| 文件 | 使用场景 |
|---|---|
| 通过 |
| 查询导入路径、全局 API 访问、tracer/meter/logger 使用、属性、传播、日志桥接(zap、slog)。 |
| 选择或对接社区贡献库(otelhttp、otelgrpc、数据库、AWS、消息队列、propagators、资源探测器),以及编写符合 semconv 的手动 instrumentation。 |
| 调优采样、批处理处理器、指标读取器、导出器压缩/重试、属性分配、日志 |
| 检查现有代码中已废弃的调用、重命名的语义约定以及近期 SDK/社区贡献版本中移除的 API。 |
| 使用 |
对于升级评审,务必完成安全的本地验证流程(、 和 )。针对导出器 URL 或重试变更,应在一次性本地接收器上测试,切勿直接使用部署端点。
go mod tidy -diffgo build ./...go test ./...Module versioning — read before adding dependencies
模块版本控制 —— 添加依赖前必读
opentelemetry-go is split into independently versioned module groups. They do NOT
share one version number. Assuming they do is the most common cause of broken builds
and version churn:
| Module group | Example modules | Version line |
|---|---|---|
| Stable signals (traces, metrics) | | v1.x (e.g. v1.45.0) |
| Logs | | v0.x (separate, lower line) |
| Contrib instrumentation | | v0.x (separate line, e.g. v0.70.0) |
| Contrib log bridges | | v0.x |
The trap: pinning every module to the core version (e.g. )
fails — log and bridge modules have no v1.x tag. Hand-picking and re-guessing each
is the churn to avoid.
go get go.opentelemetry.io/otel/log@v1.45.0@vXDo this instead — add each module with and let Go resolve a compatible set:
@latestbash
go get go.opentelemetry.io/otel@latest go.opentelemetry.io/otel/sdk@latestopentelemetry-go 被划分为独立版本控制的模块组。它们并不共享同一个版本号。假设它们版本一致是导致构建失败和版本混乱的最常见原因:
| 模块组 | 示例模块 | 版本系列 |
|---|---|---|
| 稳定信号(追踪、指标) | | v1.x (e.g. v1.45.0) |
| 日志 | | v0.x(独立的低版本系列) |
| 社区贡献 instrumentation | | v0.x(独立版本系列,例如 v0.70.0) |
| 社区贡献日志桥接 | | v0.x |
常见陷阱: 将每个模块固定为核心版本(例如 )会失败——日志和桥接模块没有 v1.x 标签。手动挑选并反复猜测每个 版本会导致不必要的版本混乱。
go get go.opentelemetry.io/otel/log@v1.45.0@vX正确做法 —— 使用 添加每个模块,让 Go 自动解析兼容版本集:
@latestbash
go get go.opentelemetry.io/otel@latest go.opentelemetry.io/otel/sdk@latestlogs (separate v0.x line — do NOT force the core version):
日志(独立的 v0.x 系列——请勿强制使用核心版本):
go get go.opentelemetry.io/otel/log@latest go.opentelemetry.io/otel/sdk/log@latest
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp@latest
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp@latest
go get go.opentelemetry.io/otel/log@latest go.opentelemetry.io/otel/sdk/log@latest
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp@latest
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp@latest
contrib (instrumentation and bridges each resolve to their own v0.x line):
社区贡献库(instrumentation 和桥接各自解析到对应的 v0.x 系列):
go get go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp@latest
go.opentelemetry.io/contrib/bridges/otelslog@latest go mod tidy && go build ./...
go.opentelemetry.io/contrib/bridges/otelslog@latest go mod tidy && go build ./...
If exact versions are required, fetch each module group's tag from its own source
(see below) — never infer one group's version from another's.go get go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp@latest
go.opentelemetry.io/contrib/bridges/otelslog@latest go mod tidy && go build ./...
go.opentelemetry.io/contrib/bridges/otelslog@latest go mod tidy && go build ./...
如果需要精确版本,请从每个模块组的官方源获取标签(见下文)——切勿从一个模块组的版本推断另一个模块组的版本。Sources of Truth
权威信息来源
For YAML schema details, fetch the upstream sources listed in the skill.
For Go-specific facts:
otel-declarative-config| Fact | Fetch |
|---|---|
Latest | |
Latest | |
Latest | |
| Latest semconv package version | |
| |
| |
如需了解 YAML Schema 细节,请参考 技能中列出的上游源。针对 Go 语言相关的信息:
otel-declarative-config| 信息内容 | 获取方式 |
|---|---|
| |
| |
| |
| semconv 包最新版本 | |
| |
| |
Cross-References
交叉引用
- Schema-level facts: skill (language-agnostic YAML schema sources).
otel-declarative-config - SDK version selection across languages: skill.
otel-sdk-versions - Semantic conventions lookup: skill.
otel-semantic-conventions
- Schema 层面信息:技能(语言无关的 YAML Schema 源)。
otel-declarative-config - 多语言 SDK 版本选择:技能。
otel-sdk-versions - 语义约定查询:技能。
otel-semantic-conventions