APM Integration
Usage
Use OpenTracing
- Method 1: inject Tracer provided by APM system through reading system parameters
Add startup arguments
-Dorg.apache.shardingsphere.tracing.opentracing.tracer.class=org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer
Call initialization method.
ShardingTracer.init();
- Method 2: inject Tracer provided by APM through parameter.
ShardingTracer.init(new SkywalkingTracer());
Notice: when using SkyWalking OpenTracing agent, the OpenTracing plug-in of Apache ShardingSphere Agent cannot be used at the same time to prevent the two plug-ins from conflicting with each other.
Use SkyWalking’s Automatic Agent
Please refer to SkyWalking Manual.
Use OpenTelemetry
Just fill in the configuration in agent.yaml
. For example, export Traces data to Zipkin.
OpenTelemetry:
props:
otel.resource.attributes: "service.name=shardingsphere-agent"
otel.traces.exporter: "zipkin"
otel.exporter.zipkin.endpoint: "http://127.0.0.1:9411/api/v2/spans"
Result Demonstration
No matter in which way, it is convenient to demonstrate APM information in the connected system. Take SkyWalking for example:
Application Architecture
Use ShardingSphere-Proxy
to visit two databases, 192.168.0.1:3306
and 192.168.0.2:3306
, and there are two tables in each one of them.
Topology
It can be seen from the picture that the user has accessed ShardingSphere-Proxy 18 times, with each database twice each time. It is because two tables in each database are accessed each time, so there are totally four tables accessed each time.
Tracking Data
SQL parsing and implementation can be seen from the tracing diagram.
/Sharding-Sphere/parseSQL/
indicates the SQL parsing performance this time.
/Sharding-Sphere/executeSQL/
indicates the SQL parsing performance in actual execution.
Exception
Exception nodes can be seen from the tracing diagram.
/Sharding-Sphere/executeSQL/
indicates the exception results of SQL.
/Sharding-Sphere/executeSQL/
indicates the exception log of SQL execution.