Use Norms

Compile source code

Download Apache ShardingSphere from GitHub,Then compile.

  1. git clone --depth 1 https://github.com/apache/shardingsphere.git
  2. cd shardingsphere
  3. mvn clean install -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests -Prelease

Output directory: shardingsphere-agent/shardingsphere-agent-distribution/target/apache-shardingsphere-${latest.release.version}-shardingsphere-agent-bin.tar.gz

Agent configuration

  • Directory structure

    Create agent directory, and unzip agent distribution package to the directory.

  1. mkdir agent
  2. tar -zxvf apache-shardingsphere-${latest.release.version}-shardingsphere-agent-bin.tar.gz -C agent
  3. cd agent
  4. tree
  5. .
  6. ├── conf
  7. ├── agent.yaml
  8. └── logback.xml
  9. ├── plugins
  10. ├── shardingsphere-agent-logging-base-${latest.release.version}.jar
  11. ├── shardingsphere-agent-metrics-prometheus-${latest.release.version}.jar
  12. ├── shardingsphere-agent-tracing-jaeger-${latest.release.version}.jar
  13. ├── shardingsphere-agent-tracing-opentelemetry-${latest.release.version}.jar
  14. ├── shardingsphere-agent-tracing-opentracing-${latest.release.version}.jar
  15. └── shardingsphere-agent-tracing-zipkin-${latest.release.version}.jar
  16. └── shardingsphere-agent.jar
  • Configuration file

agent.yaml is a configuration file. The plug-ins include Jaeger, opentracing, Zipkin, opentelemetry, logging and Prometheus. Remove the corresponding plug-in in ignoredpluginnames to start the plug-in.

  1. applicationName: shardingsphere-agent
  2. ignoredPluginNames:
  3. - Jaeger
  4. - OpenTracing
  5. - Zipkin
  6. - OpenTelemetry
  7. - Logging
  8. - Prometheus
  9. plugins:
  10. Prometheus:
  11. host: "localhost"
  12. port: 9090
  13. props:
  14. JVM_INFORMATION_COLLECTOR_ENABLED : "true"
  15. Jaeger:
  16. host: "localhost"
  17. port: 5775
  18. props:
  19. SERVICE_NAME: "shardingsphere-agent"
  20. JAEGER_SAMPLER_TYPE: "const"
  21. JAEGER_SAMPLER_PARAM: "1"
  22. Zipkin:
  23. host: "localhost"
  24. port: 9411
  25. props:
  26. SERVICE_NAME: "shardingsphere-agent"
  27. URL_VERSION: "/api/v2/spans"
  28. SAMPLER_TYPE: "const"
  29. SAMPLER_PARAM: "1"
  30. OpenTracing:
  31. props:
  32. OPENTRACING_TRACER_CLASS_NAME: "org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer"
  33. OpenTelemetry:
  34. props:
  35. otel.resource.attributes: "service.name=shardingsphere-agent"
  36. otel.traces.exporter: "zipkin"
  37. Logging:
  38. props:
  39. LEVEL: "INFO"
  • Parameter description:
NameDescriptionValue rangeDefault value
JVM_INFORMATION_COLLECTOR_ENABLEDStart JVM collectortrue、falsetrue
SERVICE_NAMETracking service nameCustomshardingsphere-agent
JAEGER_SAMPLER_TYPEJaeger sample rate typeconst、probabilistic、ratelimiting、remoteconst
JAEGER_SAMPLER_PARAMJaeger sample rate parameterconst:0、1, probabilistic:0.0 - 1.0, ratelimiting: > 0, Customize the number of acquisitions per second,remote:need to customize the remote service addres,JAEGER_SAMPLER_MANAGER_HOST_PORT1(const type)
SAMPLER_TYPEZipkin sample rate typeconst、counting、ratelimiting、boundaryconst
SAMPLER_PARAMZipkin sampling rate parameterconst:0、1, counting:0.01 - 1.0, ratelimiting: > 0, boundary:0.0001 - 1.01(const type)
otel.resource.attributesopentelemetry propertiesString key value pair (, split)service.name=shardingsphere-agent
otel.traces.exporterTracing expoterzipkin、jaegerzipkin
otel.traces.samplerOpentelemetry sample rate typealways_on、always_off、traceidratioalways_on
otel.traces.sampler.argOpentelemetry sample rate parametertraceidratio:0.0 - 1.01.0

Used in ShardingSphere-Proxy

  • Startup script

Configure the absolute path of shardingsphere-agent.jar to the start.sh startup script of shardingsphere proxy.

  1. nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} \
  2. -javaagent:/xxxxx/agent/shardingsphere-agent.jar \
  3. -classpath ${CLASS_PATH} ${MAIN_CLASS} >> ${STDOUT_FILE} 2>&1 &
  • Launch plugin
  1. bin/start.sh

After normal startup, you can view the startup log of the plugin in the shardingsphere proxy log, and you can view the data at the configured address.