opentelemetry-java-instrumentation
opentelemetry-java-instrumentation copied to clipboard
Update route attribute for apache shenyu
Is your feature request related to a problem? Please describe.
When using Apache Shenyu, the server span has no route attribute because Apache Shenyu use customized SpringWebflux WebHandler.
Describe the solution you'd like
The workflow of apache shenyu is as follows
- The downstream services register themselves to Shenyu Admin and specify the corresponding path for each downstream service.
- The Shenyu Broker communicates with the Shenyu Admin and pulls all downstream services.
- The upstream application requests the Shenyu Gateway, which gets the meta-information of the downstream service based on the requested HTTP Path, and forwards the request to the downstream
From the above workflow, the services in the gateway can be distinguished into several different groups by the path in the HTTP request received by the Apache Shenyu Broker. Therefore, when the Apache Shenyu Gateway receives an HTTP request and matches the corresponding MetaData based on the HTTP request's path, it can use the request path of this MetaData as the route of the Server Span, and this route is low-cardinality. When there is no match to the corresponding MetaData, it means that it may be accessing the extranet through the gateway, and then the Request Path is high base and no route update will be done in this senario.
When we implement it, we follow the following process
- After the
org.apache.shenyu.plugin.global.DefaultShenyuContextBuilder#build
method completes, put the generated MetaData and put it into the ServerWebExchange. - When the
org.apache.shenyu.plugin.global.GlobalPlugin#execute
method executes, get the path of the corresponding MetaData from the ServerWebExchange and update the route of the span.
Describe alternatives you've considered
record the name of Metadata as the route of the span.
Additional context
No response
related to #5629
Merged into v2.4.0