janiussyafiq opened a new pull request, #13265:
URL: https://github.com/apache/apisix/pull/13265

   ### Description
   
   The `opentelemetry` plugin supports `additional_attributes` to inject APISIX
   variables (e.g. `consumer_name`, `balancer_ip`) as span attributes. However,
   these attributes were silently missing from traces when the variable is set 
by
   a lower-priority plugin.
   
   **Root cause:** `additional_attributes` were collected during the `rewrite`
   phase, where the `opentelemetry` plugin runs first (priority `12009`). At 
that
   point, authentication plugins like `jwt-auth` (priority `2510`) have not yet
   executed, so variables such as `consumer_name` are still `nil` and silently
   skipped by `inject_attributes`. The same applies to `balancer_ip`, which is
   only set after the balancer phase.
   
   **Fix:** Move `additional_attributes` and 
`additional_header_prefix_attributes`
   injection to the `log` phase, where all variables are fully populated. This
   reuses the existing `span:set_attributes()` pattern already present in the 
log
   phase for `http.status_code` and `apisix.response_source`.
   
   #### Which issue(s) this PR fixes:
   
   Fixes #12873
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [ ] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)
   


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