Skip to main content
Version: 2.4.2

Tracing

This article introduces how to use the Apache ShenYu Agent Tracing.

Apache ShenYu uses java agent and bytecode enhancement technology to achieve seamless embedding, so that users can access third-party observability systems without introducing dependencies, and obtain Traces, Metrics and Logging.

Catalog Structure#

.โ”œโ”€โ”€ confโ”‚ย ย  โ”œโ”€โ”€ logback.xmlโ”‚ย ย  โ”œโ”€โ”€ shenyu-agent.yamlโ”‚ย ย  โ””โ”€โ”€ tracing-point.yamlโ”œโ”€โ”€ pluginsโ”‚ย ย  โ”œโ”€โ”€ shenyu-agent-plugin-tracing-common-${latest.release.version}.jarโ”‚ย ย  โ”œโ”€โ”€ shenyu-agent-plugin-tracing-jaeger-${latest.release.version}.jarโ”‚ย ย  โ”œโ”€โ”€ shenyu-agent-plugin-tracing-opentelemetry-${latest.release.version}.jarโ”‚ย ย  โ””โ”€โ”€ shenyu-agent-plugin-tracing-zipkin-${latest.release.version}.jarโ””โ”€โ”€ shenyu-agent.jar

Edit shenyu-agent.yaml#

appName: shenyu-agentsupports:  tracing:    - jaeger    - opentelemetry    - zipkin
plugins:  tracing:    jaeger:      host: "localhost"      port: 5775      props:        SERVICE_NAME: "shenyu-agent"        JAEGER_SAMPLER_TYPE: "const"        JAEGER_SAMPLER_PARAM: "1"    zipkin:      host:       port:       props:    opentelemetry:      props:        otel.traces.exporter: jaeger #zipkin #otlp        otel.resource.attributes: "service.name=shenyu-agent"        otel.exporter.jaeger.endpoint: "http://localhost:14250/api/traces"
  • Select the plugin to be used in supports
  • Configure the parameters of the plug-in in plugins. The specific usage of each plug-in props parameter is shown in the following tables:

jaeger#

NameTypeDefaultDescription
SERVICE_NAMEStringshenyu-agentThe name displayed in the traces system
JAEGER_SAMPLER_TYPEStringconstJaeger sample rate type
JAEGER_SAMPLER_PARAMString1Jaeger sample rate parameters

opentelemetry#

NameTypeDefaultDescription
otel.traces.exporterStringjaegerTraces exporter type, if not filled in, the default is otlp
otel.resource.attributesStringservice.name=shenyu-agentotel resource attributes, if you fill in more than one, they can be separated by commas

The SDK used by the opentelemetry plugin is initialized based on opentelemetry-sdk-extension-autoconfigure. For more usage, please refer to OpenTelemetry SDK AutoConfiguration Instructions

zipkin#
NameTypeDefaultDescription
SERVICE_NAMEStringshenyu-agentThe name displayed in the traces system
URL_VERSIONString/api/v2/spanszipkin url version
SAMPLER_TYPEStringconstzipkin sampler type
SAMPLER_PARAMString1zipkin sampler param

Agent Plugin Tracing Jaeger#

  • modify yaml file

Specify the use of the jaeger plugin via supports.tracing in the shenyu-agent.yaml file, and fill in the jaeger configuration information via plugins.tracing.

appName: shenyu-agentsupports:  tracing:    - jaeger
plugins:  tracing:    jaeger:      host: "localhost"      port: 5775      props:        SERVICE_NAME: "shenyu-agent"        JAEGER_SAMPLER_TYPE: "const"        JAEGER_SAMPLER_PARAM: "1"
  • start jaeger server

please see jaeger-quickstart to start jaeger

  • tracing test

    • Reference Deployment to start shenyu-admin.

    • Start the gateway by referring to the above procedure.

    • Refer to Quick start with Http to start shenyu-examples-http.

    • Launch a request to the gateway.

      GET http://localhost:9195/http/order/findById?id=1

      Accept: application/json

    • After a successful request, you can see that the link log has been reported to jaeger:

Agent Plugin Tracing Zipkin#

  • modify yaml file

Specify the use of the zipkin plugin via supports.tracing in the shenyu-agent.yaml file, and fill in the zipkin configuration information via plugins.tracing.

appName: shenyu-agentsupports:  tracing:    - zipkin
plugins:  tracing:    zipkin:      host: "localhost"      port: 9411      props:        SERVICE_NAME: "shenyu-agent"        URL_VERSION: "/api/v2/spans"        SAMPLER_TYPE: "const"        SAMPLER_PARAM: "1"
  • start zipkin-server

please see zipkin-quickstart to start zipkin-server .

  • tracing test

    • Reference Deployment to start shenyu-admin.

    • Start the gateway by referring to the above procedure.

    • Refer to Quick start with Http to start shenyu-examples-http.

    • Launch a request to the gateway.

      GET http://localhost:9195/http/order/findById?id=999

      Accept: application/json

    • After a successful request, you can see that the link log has been reported to zipkin:

Agent Plugin Tracing OpenTelemetry#

  • modify yaml file

Specify the use of the opentelemetry plugin via supports.tracing in the shenyu-agent.yaml file, and fill in the opentelemetry configuration information via plugins.tracing.

appName: shenyu-agentsupports:  tracing:    - opentelemetry
plugins:  tracing:    opentelemetry:      props:        otel.traces.exporter: jaeger #zipkin #otlp        otel.resource.attributes: "service.name=shenyu-agent"        otel.exporter.jaeger.endpoint: "http://localhost:14250/api/traces"
  • Start jaeger or zipkin or opentelemetry-collector according to exporter configuration

To start jaeger, please refer to jaeger-quickstart

To start zipkin, please refer to zipkin-quickstart

To start otel-collector, please refer to opentelemetry-collector-quickstart

  • tracing test

    • Reference Deployment to start shenyu-admin.

    • Start the gateway by referring to the above procedure.

    • Refer to Quick start with Http to start shenyu-examples-http.

    • Launch a request to the gateway.

      GET http://localhost:9195/http/order/findById?id=999

      Accept: application/json

    • After the request is successful, you can see the link log in the corresponding backend, the effect is the same as the above jaeger plugin and zipkin plugin.