opentelemetry-java-instrumentation icon indicating copy to clipboard operation
opentelemetry-java-instrumentation copied to clipboard

Update route attribute for apache shenyu

Open 123liuziming opened this issue 10 months ago • 1 comments

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

image

The workflow of apache shenyu is as follows

  1. The downstream services register themselves to Shenyu Admin and specify the corresponding path for each downstream service.
  2. The Shenyu Broker communicates with the Shenyu Admin and pulls all downstream services.
  3. 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

  1. After the org.apache.shenyu.plugin.global.DefaultShenyuContextBuilder#build method completes, put the generated MetaData and put it into the ServerWebExchange.
  2. 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.

image

Describe alternatives you've considered

record the name of Metadata as the route of the span.

Additional context

No response

123liuziming avatar Apr 26 '24 09:04 123liuziming

related to #5629

123liuziming avatar Apr 26 '24 09:04 123liuziming

Merged into v2.4.0

123liuziming avatar May 18 '24 11:05 123liuziming