otel-instrumentation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OpenTelemetry Instrumentation Guide

OpenTelemetry 埋点实施指南

Expert guidance for implementing high-quality, cost-efficient OpenTelemetry telemetry.
关于实施高质量、高性价比OpenTelemetry遥测的专业指南。

Rules

规则

RuleDescription
telemetryEntrypoint - signal types, correlation, and navigation
resolve-valuesResolving configuration values from the codebase
resourcesResource attributes - service identity and environment
k8sKubernetes deployment - downward API, pod spec
spansSpans - naming, kind, status, and hygiene
logsLogs - structured logging, severity, trace correlation
metricsMetrics - instrument types, naming, units, cardinality
nodejsNode.js instrumentation setup
goGo instrumentation setup
pythonPython instrumentation setup
javaJava instrumentation setup
scalaScala instrumentation setup
dotnet.NET instrumentation setup
rubyRuby instrumentation setup
phpPHP instrumentation setup
browserBrowser instrumentation setup
nextjsNext.js full-stack instrumentation (App Router)
规则描述
telemetry入口规则 - 信号类型、关联与导航
resolve-values从代码库中解析配置值
resources资源属性 - 服务标识与环境
k8sKubernetes 部署 - Downward API、Pod 规格
spansSpan - 命名、类型、状态与规范
logs日志 - 结构化日志、日志级别、链路关联
metrics指标 - 埋点类型、命名、单位、基数
nodejsNode.js 埋点设置
goGo 埋点设置
pythonPython 埋点设置
javaJava 埋点设置
scalaScala 埋点设置
dotnet.NET 埋点设置
rubyRuby 埋点设置
phpPHP 埋点设置
browser浏览器端埋点设置
nextjsNext.js 全栈埋点设置(App Router)

Official documentation

官方文档

Key principles

核心原则

Signal density over volume

重信号密度而非数量

Every telemetry item should serve one of three purposes:
  • Detect - Help identify that something is wrong
  • Localize - Help pinpoint where the problem is
  • Explain - Help understand why it happened
If it doesn't serve one of these purposes, don't emit it.
每条遥测数据应满足以下三个用途之一:
  • 检测 - 帮助识别异常情况
  • 定位 - 帮助精准定位问题位置
  • 解释 - 帮助理解问题发生原因
如果不满足其中任一用途,则无需生成该数据。

Sample in the pipeline, not the SDK

在管道中采样,而非SDK中

Use the
AlwaysOn
sampler (the default) in every SDK. Do not configure SDK-side samplers — they make irreversible decisions before the outcome of a request is known. Defer all sampling to the Collector, where policies can be changed centrally without redeploying applications.
SDK (AlwaysOn)  →  Collector (sampling)  →  Backend (retention)
     ↓                    ↓                       ↓
  All spans         Head or tail            Storage policies
  exported          sampling applied
在所有SDK中使用
AlwaysOn
采样器(默认配置)。 不要在SDK端配置采样器——它们会在请求结果确定前做出不可逆转的采样决策。 将所有采样操作延迟到Collector中执行,这样可以在无需重新部署应用的情况下集中修改采样策略。
SDK (AlwaysOn)  →  Collector (sampling)  →  Backend (retention)
     ↓                    ↓                       ↓
  All spans         Head or tail            Storage policies
  exported          sampling applied

Quick reference

快速参考

Use CaseRule
Node.js backendnodejs
Go backendgo
Python backendpython
Java backendjava
Scala backendscala
.NET backenddotnet
Ruby backendruby
PHP backendphp
Browser frontendbrowser
Next.js (App Router)nextjs
Kubernetes pod speck8s
Resolve config valuesresolve-values
Resource attributesresources
Writing metricsmetrics
Cardinality managementmetrics
Span naming, kind, statusspans
Writing logslogs
Signal overviewtelemetry
使用场景对应规则
Node.js 后端nodejs
Go 后端go
Python 后端python
Java 后端java
Scala 后端scala
.NET 后端dotnet
Ruby 后端ruby
PHP 后端php
浏览器前端browser
Next.js(App Router)nextjs
Kubernetes Pod 规格k8s
解析配置值resolve-values
资源属性resources
指标编写metrics
基数管理metrics
Span 命名、类型、状态spans
日志编写logs
信号概览telemetry