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

   ### Description
   
   The `opentelemetry` plugin only emits a `SERVER` span and propagates that 
span's id to the upstream. The upstream's `SERVER` span is therefore parented 
to a `SERVER` span, and APM service maps (Tempo, HyperDX, Datadog, the 
collector `servicegraph` connector) never draw the gateway -> upstream edge, so 
APISIX shows up as a disconnected node.
   
   This PR adds a child `CLIENT` span named `apisix.upstream` for the call to 
the upstream:
   
   - `rewrite`: start the `CLIENT` span under the `SERVER` span and propagate 
its context in `traceparent`, so the upstream's span becomes its child.
   - `before_proxy`: record the start time (runs per try).
   - `log`: set `server.address`, `server.port` and 
`http.response.status_code`, mark 5xx or unreachable upstream as error, end the 
span using `$upstream_response_time` and finish it before the `SERVER` span.
   
   A request answered before being proxied never finishes the span, so nothing 
is exported for it. `$opentelemetry_span_id` and related variables keep 
referring to the `SERVER` span.
   
   Verified with an OTel-instrumented upstream behind APISIX: Tempo's service 
graph gains the `apisix-gw -> upstream` edge, and Jaeger shows the upstream 
span under `apisix.upstream`.
   
   #### Which issue(s) this PR fixes:
   
   Fixes #13945
   
   ### 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
   - [x] 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