kayx23 commented on code in PR #11900:
URL: https://github.com/apache/apisix/pull/11900#discussion_r1917860848


##########
docs/zh/latest/plugins/opentelemetry.md:
##########
@@ -27,163 +27,181 @@ description: 本文介绍了关于 Apache APISIX `opentelemetry` 插件的基本
 #
 -->
 
+<head>
+  <link rel="canonical" href="https://docs.api7.ai/hub/opentelemetry"; />
+</head>
+
 ## 描述
 
-`opentelemetry` 插件可用于根据 [OpenTelemetry 
specification](https://opentelemetry.io/docs/reference/specification/) 协议规范上报 
Tracing 数据。
+`opentelemetry` 插件可用于根据 [OpenTelemetry 
Specification](https://opentelemetry.io/docs/reference/specification/) 协议规范上报 
Traces 数据。该插件仅支持二进制编码的 OLTP over HTTP,即请求类型为 `application/x-protobuf` 的数据上报。
 
-该插件仅支持二进制编码的 [OLTP over 
HTTP](https://opentelemetry.io/docs/reference/specification/protocol/otlp/#otlphttp),即请求类型为
 `application/x-protobuf` 的数据上报。
+## 静态配置
 
-## 属性
+默认情况下,服务名称、租户 ID、collector 和 batch span processor 
的配置已预配置在[默认配置](https://github.com/apache/apisix/blob/master/apisix/cli/config.lua)中。
+
+要自定义这些值,请将相应的配置添加到 `config.yaml` 中。例如:
 
-| 名称                                  | 类型           | 必选项 | 默认值               
                            | 有效值                                               
       | 描述                                                  |
-| ------------------------------------- | ------------- | ------ | 
----------------------------------------------- | 
------------------------------------------------------------ | 
----------------------------------------------------- |
-| sampler                               | object        | 否     |              
                                   |                                            
                  | 采样策略。 |
-| sampler.name                          | string        | 否     | always_off   
                                   | ["always_on", "always_off", 
"trace_id_ratio", "parent_base"] | 
采样策略。`always_on`:全采样;`always_off`:不采样;`trace_id_ratio`:基于 trace id 
的百分比采样;`parent_base`:如果存在 tracing 上游,则使用上游的采样决定,否则使用配置的采样策略决策。 |
-| sampler.options                       | object        | 否     |              
                                   | {fraction = 0, root = {name = 
"always_off"}}                 | 采样策略参数。 |
-| sampler.options.fraction              | number        | 否     | 0            
                                   | [0, 1]                                     
                  | `trace_id_ratio` 采样策略的百分比。 |
-| sampler.options.root                  | object        | 否     | {name = 
"always_off", options = {fraction = 0}} |                                       
                       | `parent_base` 采样策略在没有上游 tracing 时,会使用 root 采样策略做决策。 |
-| sampler.options.root.name             | string        | 否     | always_off   
                                   | ["always_on", "always_off", 
"trace_id_ratio"]                | root 采样策略。 |
-| sampler.options.root.options          | object        | 否     | {fraction = 
0}                                  |                                           
                   | root 采样策略参数。 |
-| sampler.options.root.options.fraction | number        | 否     | 0            
                                   | [0, 1]                                     
                  | `trace_id_ratio` root 采样策略的百分比 |
-| additional_attributes                 | array[string] | 否     |              
                                   |                                            
                  | 追加到 trace span 的额外属性,支持内置 NGINX 或 APISIX 
变量,例如:`http_header` 或者 `route_id`。 |
-| additional_header_prefix_attributes   | array[string] | False    |           
                                      |                                         
                     | 附加到跟踪范围属性的标头或标头前缀。例如,使用 `x-my-header"` 或 
`x-my-headers-*` 来包含带有前缀 `x-my-headers-` 的所有标头。                                 
                                                                                
                                                  |
-
-## 如何设置数据上报
-
-你可以通过在 `conf/config.yaml` 中指定配置来设置数据上报:
-
-| 名称                                       | 类型    | 默认值                       
                      | 描述                                                      
                                                                                
       |
-| ------------------------------------------ | ------- | 
------------------------------------------------- | 
-------------------------------------------------------------------------------------------------------------------------------------------------
 |
-| trace_id_source                            | enum    | x-request-id          
                            | trace ID 的来源。有效值为:`random` 或 `x-request-id`。当设置为 
`x-request-id` 时,`x-request-id` 头的值将用作跟踪 ID。请确保当前请求 ID 是符合 TraceID 
规范的:`[0-9a-f]{32}`。 |
-| resource                                   | object  |                       
                            | 追加到 trace 的额外 
[resource](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md)。
 |
-| collector                                  | object  | {address = 
"127.0.0.1:4318", request_timeout = 3} | OpenTelemetry Collector 配置。 |
-| collector.address                          | string  | 127.0.0.1:4318        
                            | 数据采集服务的地址。如果数据采集服务使用的是 HTTPS 协议,可以将 address 设置为 
https://127.0.0.1:4318。 |
-| collector.request_timeout                  | integer | 3                     
                            | 数据采集服务上报请求超时时长,单位为秒。 |
-| collector.request_headers                  | object  |                       
                            | 数据采集服务上报请求附加的 HTTP 请求头。 |
-| batch_span_processor                       | object  |                       
                            | trace span 处理器参数配置。 |
-| batch_span_processor.drop_on_queue_full    | boolean | false                 
                            | 如果设置为 `true` 时,则在队列排满时删除 span。否则,强制处理批次。|
-| batch_span_processor.max_queue_size        | integer | 1024                  
                            | 处理器缓存队列容量的最大值。 |
-| batch_span_processor.batch_timeout         | number  | 2                     
                            | 构造一批 span 超时时间,单位为秒。 |
-| batch_span_processor.max_export_batch_size | integer | 16                    
                            | 单个批次中要处理的 span 数量。 |
-| batch_span_processor.inactive_timeout      | number  | 1                     
                            | 两个处理批次之间的时间间隔,单位为秒。 |
-
-:::note
-
-如果你在 error log 中发现由 hex2bytes 函数引发的 `bad argument #1 to '?' (invalid value)` 
错误,务必确认你的 traceId 是否满足 opentelemetry 的 [traceId 
格式](https://opentelemetry.io/docs/specs/otel/trace/api/#retrieving-the-traceid-and-spanid)
 所需的正则规范`[0-9a-f]{32}`。
-
-例如,当插件属性 `trace_id_source` 配置为 `x-request-id` 时,如果请求包含由 Envoy 生成的 x-request-id 
请求头,可能会发生上述情况。Envoy 默认使用 
[UUID](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/tracing#trace-context-propagation)
 生成该请求头。当 opentelemetry 插件将此 UUID 作为 traceId 时,UUID 中的 `-` 可能会引起问题。由于带有 `-` 的 
UUID 格式与 traceId 格式不符,因此尝试将跟踪推送到收集器时会导致错误。
-
-:::
-
-你可以参考以下示例进行配置:
-
-```yaml title="./conf/config.yaml"
+```yaml
 plugin_attr:
   opentelemetry:
-    resource:
-      service.name: APISIX
-      tenant.id: business_id
+    trace_id_source: x-request-id     # 指定追踪 ID 的来源,`x-request-id` 或 
`random`。当设置为 `x-request-id` 时,
+                                      # `x-request-id` 头的值将用作追踪 ID。
+    resource:                         # 追加到追踪的额外资源。
+      service.name: APISIX            # 为 OpenTelemetry 追踪设置服务名称。
     collector:
-      address: 192.168.8.211:4318
-      request_timeout: 3
-      request_headers:
-        foo: bar
-    batch_span_processor:
-      drop_on_queue_full: false
-      max_queue_size: 6
-      batch_timeout: 2
-      inactive_timeout: 1
-      max_export_batch_size: 2
+      address: 127.0.0.1:4318       # 设置要发送追踪的 OpenTelemetry 收集器的地址。
+      request_timeout: 3            # 设置请求 OpenTelemetry 收集器的超时时间(秒)。
+      request_headers:              # 设置请求 OpenTelemetry 收集器时要包含的头信息。
+        Authorization: token        # 设置授权头以包含访问令牌。
+    batch_span_processor:           # 追踪跨度处理器。
+      drop_on_queue_full: false     # 当导出队列满时丢弃跨度。
+      max_queue_size: 1024          # 设置跨度导出队列的最大大小。
+      batch_timeout: 2              # 设置跨度批次在导出队列中等待的超时时间,
+                                    # 然后发送。
+      inactive_timeout: 1           # 设置跨度在导出队列中等待的超时时间,如果队列不满,则发送。
+      max_export_batch_size: 16     # 设置每个批次发送到 OpenTelemetry 收集器的跨度的最大数量。
+    set_ngx_var: false              # 将 opentelemetry 变量导出到 nginx 变量。
 ```
 
-## 如何使用变量
+重新加载 APISIX 以使更改生效。
 
-以下`nginx`变量是由`opentelemetry` 设置的。
+## 属性
 
-- `opentelemetry_context_traceparent` -  [W3C trace 
context](https://www.w3.org/TR/trace-context/#trace-context-http-headers-format),
 例如:`00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01`
-- `opentelemetry_trace_id` - 当前 span 的 trace_id
-- `opentelemetry_span_id` - 当前 span 的 span_id
+| 名称                                  | 类型           | 必选项    | 默认值        | 
有效值        | 描述 |
+|---------------------------------------|---------------|----------|--------------|--------------|-------------|
+| sampler                               | object        | 否       | -          
  | -            | 采样策略。    |
+| sampler.name                          | string        | False    | 
`always_off` | ["always_on", "always_off", "trace_id_ratio", "parent_base"]  | 
采样策略。<br>`always_on`:全采样;`always_off`:不采样;`trace_id_ratio`:基于 trace id 
的百分比采样;`parent_base`:如果存在 tracing 上游,则使用上游的采样决定,否则使用配置的采样策略决策。|
+| sampler.options                       | object        | 否       | -          
  | -            | 采样策略参数。 |
+| sampler.options.fraction              | number        | 否       | 0          
  | [0, 1]       | `trace_id_ratio`:采样策略的百分比。 |

Review Comment:
   <img width="54" alt="image" 
src="https://github.com/user-attachments/assets/eb6392d6-328d-453f-b3ef-aa883de4653c";
 />
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to