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


##########
docs/en/latest/plugins/opentelemetry.md:
##########
@@ -26,160 +27,186 @@ description: This document contains information about the 
Apache opentelemetry P
 #
 -->
 
+<head>
+  <link rel="canonical" href="https://docs.api7.ai/hub/opentelemetry"; />
+</head>
+
 ## Description
 
 The `opentelemetry` Plugin can be used to report tracing data according to the 
[OpenTelemetry 
specification](https://opentelemetry.io/docs/reference/specification/).
 
 The Plugin only supports binary-encoded [OLTP over 
HTTP](https://opentelemetry.io/docs/reference/specification/protocol/otlp/#otlphttp).
 
-## Attributes
-
-| Name                                  | Type          | Required | Default   
                                      | Valid values                            
                     | Description                                              
                                                                                
                                                                                
                    |
-|---------------------------------------|---------------|----------|-------------------------------------------------|--------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| sampler                               | object        | False    |           
                                      |                                         
                     | Sampling configuration.                                  
                                                                                
                                                                                
                    |
-| sampler.name                          | string        | False    | 
always_off                                      | ["always_on", "always_off", 
"trace_id_ratio", "parent_base"] | Sampling strategy. `always_on`: always 
samples, `always_off`: never samples, `trace_id_ratio`: random sampling result 
based on given sampling probability, `parent_base`: use parent decision if 
given, else determined by the root sampler. |
-| sampler.options                       | object        | False    |           
                                      | {fraction = 0, root = {name = 
"always_off"}}                 | Parameters for sampling strategy.              
                                                                                
                                                                                
                              |
-| sampler.options.fraction              | number        | False    | 0         
                                      | [0, 1]                                  
                     | Sampling probability for `trace_id_ratio`.               
                                                                                
                                                                                
                    |
-| sampler.options.root                  | object        | False    | {name = 
"always_off", options = {fraction = 0}} |                                       
                       | Root sampler for `parent_base` strategy.               
                                                                                
                                                                                
                      |
-| sampler.options.root.name             | string        | False    | 
always_off                                      | ["always_on", "always_off", 
"trace_id_ratio"]                | Root sampling strategy.                      
                                                                                
                                                                                
                                |
-| sampler.options.root.options          | object        | False    | {fraction 
= 0}                                  |                                         
                     | Root sampling strategy parameters.                       
                                                                                
                                                                                
                    |
-| sampler.options.root.options.fraction | number        | False    | 0         
                                      | [0, 1]                                  
                     | Root sampling probability for `trace_id_ratio`.          
                                                                                
                                                                                
                    |
-| additional_attributes                 | array[string] | False    |           
                                      |                                         
                     | Additional attributes appended to the trace span. 
Support built-in NGINX or APISIX variables in values, such as `http_header` or 
`route_id`.                                                                     
                                                                                
                     |
-| additional_header_prefix_attributes   | array[string] | False    |           
                                      |                                         
                     | Headers or header prefixes appended to the trace span's 
attributes. For example, use `x-my-header"` or `x-my-headers-*` to include all 
headers with the prefix `x-my-headers-`.                                        
                                                                                
                                           |
-
-### Configuring the collector
-
-You can set up the collector by configuring it in you configuration file 
(`conf/config.yaml`):
-
-| Name                                       | Type    | Default               
                            | Description                                       
                                                                                
                                                                                
            |
-|--------------------------------------------|---------|---------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| trace_id_source                            | enum    | x-request-id          
                            | Source of the trace ID. Valid values are `random` 
or `x-request-id`. When set to `x-request-id`, the value of the `x-request-id` 
header will be used as trace ID. Make sure that it matches the regex pattern 
`[0-9a-f]{32}`. |
-| resource                                   | object  |                       
                            | Additional 
[resource](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md)
 appended to the trace.                                                         
                  |
-| collector                                  | object  | {address = 
"127.0.0.1:4318", request_timeout = 3} | OpenTelemetry Collector configuration. 
                                                                                
                                                                                
                       |
-| collector.address                          | string  | 127.0.0.1:4318        
                            | Collector address. If the collector serves on 
https, use https://127.0.0.1:4318 as the address.                               
                                                                                
                     |
-| collector.request_timeout                  | integer | 3                     
                            | Report request timeout in seconds.                
                                                                                
                                                                                
            |
-| collector.request_headers                  | object  |                       
                            | Report request HTTP headers.                      
                                                                                
                                                                                
            |
-| batch_span_processor                       | object  |                       
                            | Trace span processor.                             
                                                                                
                                                                                
            |
-| batch_span_processor.drop_on_queue_full    | boolean | false                 
                            | When set to `true`, drops the span when queue is 
full. Otherwise, force process batches.                                         
                                                                                
             |
-| batch_span_processor.max_queue_size        | integer | 1024                  
                            | Maximum queue size for buffering spans for 
delayed processing.                                                             
                                                                                
                   |
-| batch_span_processor.batch_timeout         | number  | 2                     
                            | Maximum time in seconds for constructing a batch. 
                                                                                
                                                                                
            |
-| batch_span_processor.max_export_batch_size | integer | 16                    
                            | Maximum number of spans to process in a single 
batch.                                                                          
                                                                                
               |
-| batch_span_processor.inactive_timeout      | number  | 1                     
                            | Time interval in seconds between processing 
batches.                                                                        
                                                                                
                  |
+## Static Configurations
 
-:::note
+By default, configurations of the Service name, tenant ID, collector, and 
batch span processor are pre-configured in [default 
configuration](https://github.com/apache/apisix/blob/master/apisix/cli/config.lua).
 
-If you find a `bad argument #1 to '?' (invalid value)` error triggered by the 
`hex2bytes` function in error log, it's essential to verify if your traceId 
matches the specified regex pattern `[0-9a-f]{32}`, as required by 
opentelemetry's [traceId 
format](https://opentelemetry.io/docs/specs/otel/trace/api/#retrieving-the-traceid-and-spanid).
+To customize these values, add the corresponding configurations to 
`config.yaml`. For example:
 
-For instance, a possible scenario occurs when the plugin attribute 
`trace_id_source` is configured as `x-request-id`, and requests include an 
x-request-id header generated by Envoy. Envoy typically uses a 
[UUID](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/tracing#trace-context-propagation)
 to create this header by default. When the opentelemetry plugin adopts this 
UUID as the traceId, the presence of hyphens in the UUID can cause issues. 
Since the UUID format with hyphens does not comply with the expected traceId 
format, it results in errors when attempting to push traces to the collector.
-
-:::
-
-You can configure these as shown below in your configuration file 
(`conf/config.yaml`):
-
-```yaml title="conf/config.yaml"
+```yaml
 plugin_attr:
   opentelemetry:
-    resource:
-      service.name: APISIX
-      tenant.id: business_id
+    trace_id_source: x-request-id     # Specify the source of the trace ID, 
`x-request-id` or `random`. When set to `x-request-id`,
+                                      # the value of the `x-request-id` header 
will be used as the trace ID.
+    resource:                         # Additional resource to append to the 
trace.
+      service.name: APISIX            # Set the Service name for OpenTelemetry 
traces.
     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       # Set the address of the OpenTelemetry 
collector to send traces to.
+      request_timeout: 3            # Set the timeout for requests to the 
OpenTelemetry collector in seconds.
+      request_headers:              # Set the headers to include in requests 
to the OpenTelemetry collector.
+        Authorization: token        # Set the authorization header to include 
an access token.
+    batch_span_processor:           # Trace span processor.
+      drop_on_queue_full: false     # Drop spans when the export queue is full.
+      max_queue_size: 1024          # Set the maximum size of the span export 
queue.
+      batch_timeout: 2              # Set the timeout for span batches to wait 
in the export queue before
+                                    # being sent.
+      inactive_timeout: 1           # Set the timeout for spans to wait in the 
export queue before being sent,
+                                    # if the queue is not full.
+      max_export_batch_size: 16     # Set the maximum number of spans to 
include in each batch sent to the OpenTelemetry collector.
+    set_ngx_var: false              # Export opentelemetry variables to nginx 
variables.
 ```
 
-## Variables
+Reload APISIX for changes to take effect.
 
-The following nginx variables are set by OpenTelemetry:
+## Attributes
 
-- `opentelemetry_context_traceparent` -  [W3C trace 
context](https://www.w3.org/TR/trace-context/#trace-context-http-headers-format),
 e.g.: `00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01`
-- `opentelemetry_trace_id` - Trace Id of the current span
-- `opentelemetry_span_id` -  Span Id of the current span
+| Name                                  | Type          | Required | Default   
   | Valid Values | Description |
+|---------------------------------------|---------------|----------|--------------|--------------|-------------|
+| sampler                               | object        | False    | -         
   | -            | Sampling configuration. |
+| sampler.name                          | string        | False    | 
`always_off` | `always_on`, `always_off`, `trace_id_ratio`, or `parent_base` | 
Sampling strategy.<br>To always sample, use `always_on`.<br>To never sample, 
use `always_off`.<br>To randomly sample based on a given ratio, use 
`trace_id_ratio`.<br>To use the sampling decision of the span's parent, use 
`parent_base`. If there is no parent, use the root sampler. |

Review Comment:
   ```suggestion
   | sampler.name                          | string        | False    | 
`always_off` | ["always_on", "always_off", "trace_id_ratio", "parent_base"]  | 
Sampling strategy.<br>To always sample, use `always_on`.<br>To never sample, 
use `always_off`.<br>To randomly sample based on a given ratio, use 
`trace_id_ratio`.<br>To use the sampling decision of the span's parent, use 
`parent_base`. If there is no parent, use the root sampler. |
   ```
   
   for valid values I guess use the apache/apisix format to avoid confusions, 
since the valid values below and elsewhere are also using the `[]` annotations?
   
   <img width="88" alt="image" 
src="https://github.com/user-attachments/assets/58c2ad76-65ac-491b-bdc9-443fa9f9dcba";
 />
   



##########
docs/en/latest/plugins/opentelemetry.md:
##########
@@ -5,7 +5,8 @@ keywords:
   - API Gateway
   - Plugin
   - OpenTelemetry
-description: This document contains information about the Apache opentelemetry 
Plugin.
+description: The `opentelemetry` Plugin instruments APISIX and sends traces to 
OpenTelemetry collector based on the OpenTelemetry specification, in 
binary-encoded OLTP over HTTP.

Review Comment:
   ```suggestion
   description: The opentelemetry Plugin instruments APISIX and sends traces to 
OpenTelemetry collector based on the OpenTelemetry specification, in 
binary-encoded OLTP over HTTP.
   ```



##########
docs/en/latest/plugins/opentelemetry.md:
##########
@@ -26,160 +27,186 @@ description: This document contains information about the 
Apache opentelemetry P
 #
 -->
 
+<head>
+  <link rel="canonical" href="https://docs.api7.ai/hub/opentelemetry"; />
+</head>
+
 ## Description
 
 The `opentelemetry` Plugin can be used to report tracing data according to the 
[OpenTelemetry 
specification](https://opentelemetry.io/docs/reference/specification/).
 
 The Plugin only supports binary-encoded [OLTP over 
HTTP](https://opentelemetry.io/docs/reference/specification/protocol/otlp/#otlphttp).
 
-## Attributes
-
-| Name                                  | Type          | Required | Default   
                                      | Valid values                            
                     | Description                                              
                                                                                
                                                                                
                    |
-|---------------------------------------|---------------|----------|-------------------------------------------------|--------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| sampler                               | object        | False    |           
                                      |                                         
                     | Sampling configuration.                                  
                                                                                
                                                                                
                    |
-| sampler.name                          | string        | False    | 
always_off                                      | ["always_on", "always_off", 
"trace_id_ratio", "parent_base"] | Sampling strategy. `always_on`: always 
samples, `always_off`: never samples, `trace_id_ratio`: random sampling result 
based on given sampling probability, `parent_base`: use parent decision if 
given, else determined by the root sampler. |
-| sampler.options                       | object        | False    |           
                                      | {fraction = 0, root = {name = 
"always_off"}}                 | Parameters for sampling strategy.              
                                                                                
                                                                                
                              |
-| sampler.options.fraction              | number        | False    | 0         
                                      | [0, 1]                                  
                     | Sampling probability for `trace_id_ratio`.               
                                                                                
                                                                                
                    |
-| sampler.options.root                  | object        | False    | {name = 
"always_off", options = {fraction = 0}} |                                       
                       | Root sampler for `parent_base` strategy.               
                                                                                
                                                                                
                      |
-| sampler.options.root.name             | string        | False    | 
always_off                                      | ["always_on", "always_off", 
"trace_id_ratio"]                | Root sampling strategy.                      
                                                                                
                                                                                
                                |
-| sampler.options.root.options          | object        | False    | {fraction 
= 0}                                  |                                         
                     | Root sampling strategy parameters.                       
                                                                                
                                                                                
                    |
-| sampler.options.root.options.fraction | number        | False    | 0         
                                      | [0, 1]                                  
                     | Root sampling probability for `trace_id_ratio`.          
                                                                                
                                                                                
                    |
-| additional_attributes                 | array[string] | False    |           
                                      |                                         
                     | Additional attributes appended to the trace span. 
Support built-in NGINX or APISIX variables in values, such as `http_header` or 
`route_id`.                                                                     
                                                                                
                     |
-| additional_header_prefix_attributes   | array[string] | False    |           
                                      |                                         
                     | Headers or header prefixes appended to the trace span's 
attributes. For example, use `x-my-header"` or `x-my-headers-*` to include all 
headers with the prefix `x-my-headers-`.                                        
                                                                                
                                           |
-
-### Configuring the collector
-
-You can set up the collector by configuring it in you configuration file 
(`conf/config.yaml`):
-
-| Name                                       | Type    | Default               
                            | Description                                       
                                                                                
                                                                                
            |
-|--------------------------------------------|---------|---------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| trace_id_source                            | enum    | x-request-id          
                            | Source of the trace ID. Valid values are `random` 
or `x-request-id`. When set to `x-request-id`, the value of the `x-request-id` 
header will be used as trace ID. Make sure that it matches the regex pattern 
`[0-9a-f]{32}`. |
-| resource                                   | object  |                       
                            | Additional 
[resource](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md)
 appended to the trace.                                                         
                  |
-| collector                                  | object  | {address = 
"127.0.0.1:4318", request_timeout = 3} | OpenTelemetry Collector configuration. 
                                                                                
                                                                                
                       |
-| collector.address                          | string  | 127.0.0.1:4318        
                            | Collector address. If the collector serves on 
https, use https://127.0.0.1:4318 as the address.                               
                                                                                
                     |
-| collector.request_timeout                  | integer | 3                     
                            | Report request timeout in seconds.                
                                                                                
                                                                                
            |
-| collector.request_headers                  | object  |                       
                            | Report request HTTP headers.                      
                                                                                
                                                                                
            |
-| batch_span_processor                       | object  |                       
                            | Trace span processor.                             
                                                                                
                                                                                
            |
-| batch_span_processor.drop_on_queue_full    | boolean | false                 
                            | When set to `true`, drops the span when queue is 
full. Otherwise, force process batches.                                         
                                                                                
             |
-| batch_span_processor.max_queue_size        | integer | 1024                  
                            | Maximum queue size for buffering spans for 
delayed processing.                                                             
                                                                                
                   |
-| batch_span_processor.batch_timeout         | number  | 2                     
                            | Maximum time in seconds for constructing a batch. 
                                                                                
                                                                                
            |
-| batch_span_processor.max_export_batch_size | integer | 16                    
                            | Maximum number of spans to process in a single 
batch.                                                                          
                                                                                
               |
-| batch_span_processor.inactive_timeout      | number  | 1                     
                            | Time interval in seconds between processing 
batches.                                                                        
                                                                                
                  |
+## Static Configurations
 
-:::note
+By default, configurations of the Service name, tenant ID, collector, and 
batch span processor are pre-configured in [default 
configuration](https://github.com/apache/apisix/blob/master/apisix/cli/config.lua).
 
-If you find a `bad argument #1 to '?' (invalid value)` error triggered by the 
`hex2bytes` function in error log, it's essential to verify if your traceId 
matches the specified regex pattern `[0-9a-f]{32}`, as required by 
opentelemetry's [traceId 
format](https://opentelemetry.io/docs/specs/otel/trace/api/#retrieving-the-traceid-and-spanid).
+To customize these values, add the corresponding configurations to 
`config.yaml`. For example:
 
-For instance, a possible scenario occurs when the plugin attribute 
`trace_id_source` is configured as `x-request-id`, and requests include an 
x-request-id header generated by Envoy. Envoy typically uses a 
[UUID](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/tracing#trace-context-propagation)
 to create this header by default. When the opentelemetry plugin adopts this 
UUID as the traceId, the presence of hyphens in the UUID can cause issues. 
Since the UUID format with hyphens does not comply with the expected traceId 
format, it results in errors when attempting to push traces to the collector.
-
-:::
-
-You can configure these as shown below in your configuration file 
(`conf/config.yaml`):
-
-```yaml title="conf/config.yaml"
+```yaml
 plugin_attr:
   opentelemetry:
-    resource:
-      service.name: APISIX
-      tenant.id: business_id
+    trace_id_source: x-request-id     # Specify the source of the trace ID, 
`x-request-id` or `random`. When set to `x-request-id`,
+                                      # the value of the `x-request-id` header 
will be used as the trace ID.
+    resource:                         # Additional resource to append to the 
trace.
+      service.name: APISIX            # Set the Service name for OpenTelemetry 
traces.
     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       # Set the address of the OpenTelemetry 
collector to send traces to.
+      request_timeout: 3            # Set the timeout for requests to the 
OpenTelemetry collector in seconds.
+      request_headers:              # Set the headers to include in requests 
to the OpenTelemetry collector.
+        Authorization: token        # Set the authorization header to include 
an access token.
+    batch_span_processor:           # Trace span processor.
+      drop_on_queue_full: false     # Drop spans when the export queue is full.
+      max_queue_size: 1024          # Set the maximum size of the span export 
queue.
+      batch_timeout: 2              # Set the timeout for span batches to wait 
in the export queue before
+                                    # being sent.
+      inactive_timeout: 1           # Set the timeout for spans to wait in the 
export queue before being sent,
+                                    # if the queue is not full.
+      max_export_batch_size: 16     # Set the maximum number of spans to 
include in each batch sent to the OpenTelemetry collector.
+    set_ngx_var: false              # Export opentelemetry variables to nginx 
variables.
 ```
 
-## Variables
+Reload APISIX for changes to take effect.
 
-The following nginx variables are set by OpenTelemetry:
+## Attributes
 
-- `opentelemetry_context_traceparent` -  [W3C trace 
context](https://www.w3.org/TR/trace-context/#trace-context-http-headers-format),
 e.g.: `00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01`
-- `opentelemetry_trace_id` - Trace Id of the current span
-- `opentelemetry_span_id` -  Span Id of the current span
+| Name                                  | Type          | Required | Default   
   | Valid Values | Description |
+|---------------------------------------|---------------|----------|--------------|--------------|-------------|
+| sampler                               | object        | False    | -         
   | -            | Sampling configuration. |
+| sampler.name                          | string        | False    | 
`always_off` | `always_on`, `always_off`, `trace_id_ratio`, or `parent_base` | 
Sampling strategy.<br>To always sample, use `always_on`.<br>To never sample, 
use `always_off`.<br>To randomly sample based on a given ratio, use 
`trace_id_ratio`.<br>To use the sampling decision of the span's parent, use 
`parent_base`. If there is no parent, use the root sampler. |
+| sampler.options                       | object        | False    | -         
   | -            | Parameters for sampling strategy. |
+| sampler.options.fraction              | number        | False    | 0         
   | [0, 1]       | Sampling ratio when the sampling strategy is 
`trace_id_ratio`. |
+| sampler.options.root                  | object        | False    | -         
   | -            | Root sampler when the sampling strategy is `parent_base` 
strategy. |
+| sampler.options.root.name             | string        | False    | -         
   | `always_on`, `always_off`, or `trace_id_ratio` | Root sampling strategy. |

Review Comment:
   ditto



-- 
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