You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by xi...@apache.org on 2020/12/22 02:29:31 UTC

[shardingsphere] branch master updated: add zipkin plugin (#8709)

This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 0581113  add zipkin plugin (#8709)
0581113 is described below

commit 0581113fb25464f3325fcb1d7c04c0479c1f0485
Author: Daming <zt...@foxmail.com>
AuthorDate: Tue Dec 22 10:29:02 2020 +0800

    add zipkin plugin (#8709)
---
 .../shardingsphere-agent-plugins/pom.xml           | 12 ++++
 .../shardingsphere-agent-plugin-tracers/pom.xml    |  5 ++
 .../pom.xml                                        | 61 ++++++++---------
 .../plugin/trace/zipkin/ShardingConstants.java     | 62 +++++++++++++++++
 .../trace/zipkin/ZipkinPluginDefinition.java       | 55 ++++++++++++++++
 .../plugin/trace/zipkin/ZipkinTracerService.java   | 58 ++++++++++++++++
 .../zipkin/advice/CommandExecutorTaskAdvice.java   | 61 +++++++++++++++++
 .../zipkin/advice/JDBCExecutorCallbackAdvice.java  | 77 ++++++++++++++++++++++
 .../trace/zipkin/advice/SQLParserEngineAdvice.java | 56 ++++++++++++++++
 9 files changed, 412 insertions(+), 35 deletions(-)

diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/pom.xml b/shardingsphere-agent/shardingsphere-agent-plugins/pom.xml
index 1a61524..bb8b684 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/pom.xml
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/pom.xml
@@ -42,6 +42,18 @@
                 <version>${project.version}</version>
                 <scope>provided</scope>
             </dependency>
+            <dependency>
+                <groupId>org.apache.shardingsphere</groupId>
+                <artifactId>shardingsphere-proxy-common</artifactId>
+                <version>${project.version}</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.shardingsphere</groupId>
+                <artifactId>shardingsphere-proxy-frontend-core</artifactId>
+                <version>${project.version}</version>
+                <scope>provided</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>
     
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/pom.xml b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/pom.xml
index 5f0a2c9..6bfd6ea 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/pom.xml
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/pom.xml
@@ -31,6 +31,7 @@
     
     <modules>
         <module>shardingsphere-agent-tracer-jaeger</module>
+        <module>shardingsphere-agent-tracer-zipkin</module>
     </modules>
     
     <properties>
@@ -43,6 +44,10 @@
             <groupId>org.apache.shardingsphere</groupId>
             <artifactId>shardingsphere-agent-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-proxy-common</artifactId>
+        </dependency>
     </dependencies>
     
     <build>
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/pom.xml b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/pom.xml
similarity index 53%
copy from shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/pom.xml
copy to shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/pom.xml
index 5f0a2c9..9ec94e2 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/pom.xml
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/pom.xml
@@ -20,50 +20,41 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
-    <artifactId>shardingsphere-agent-plugin-tracers</artifactId>
+
     <parent>
         <groupId>org.apache.shardingsphere</groupId>
-        <artifactId>shardingsphere-agent-plugins</artifactId>
+        <artifactId>shardingsphere-agent-plugin-tracers</artifactId>
         <version>5.0.0-RC1-SNAPSHOT</version>
     </parent>
-    <packaging>pom</packaging>
-    <name>${project.artifactId}</name>
-    
-    <modules>
-        <module>shardingsphere-agent-tracer-jaeger</module>
-    </modules>
-    
+
+    <packaging>jar</packaging>
+    <artifactId>shardingsphere-agent-tracer-zipkin</artifactId>
+
     <properties>
-        <entrypoint.class/>
-        <tracing.target.directory>${project.basedir}/../target/plugins</tracing.target.directory>
+        <zipkin-reporter.version>2.16.2</zipkin-reporter.version>
+        <zipkin-brave.version>5.13.2</zipkin-brave.version>
+        <entrypoint.class>org.apache.shardingsphere.agent.plugin.trace.zipkin.ZipkinPluginDefinition</entrypoint.class>
     </properties>
-    
+
     <dependencies>
         <dependency>
+            <groupId>io.zipkin.brave</groupId>
+            <artifactId>brave</artifactId>
+            <version>${zipkin-brave.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.zipkin.reporter2</groupId>
+            <artifactId>zipkin-reporter-brave</artifactId>
+            <version>${zipkin-reporter.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.zipkin.reporter2</groupId>
+            <artifactId>zipkin-sender-okhttp3</artifactId>
+            <version>${zipkin-reporter.version}</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-agent-core</artifactId>
+            <artifactId>shardingsphere-proxy-frontend-core</artifactId>
         </dependency>
     </dependencies>
-    
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
-                <configuration>
-                    <archive>
-                        <manifestEntries>
-                            <Entrypoint>${entrypoint.class}</Entrypoint>
-                        </manifestEntries>
-                    </archive>
-                </configuration>
-            </plugin>
-            <plugin>
-                <artifactId>maven-shade-plugin</artifactId>
-                <configuration>
-                    <outputFile>${tracing.target.directory}/${project.build.finalName}</outputFile>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
 </project>
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/ShardingConstants.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/ShardingConstants.java
new file mode 100644
index 0000000..2499082
--- /dev/null
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/ShardingConstants.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.agent.plugin.trace.zipkin;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+/**
+ * Sharding tags.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ShardingConstants {
+    
+    public static final String COMPONENT_NAME = "shardingsphere";
+    
+    public static final String ROOT_SPAN = "_root_span_";
+    
+    public static final String DB_TYPE_VALUE = "shardingsphere-proxy";
+    
+    public static class Tags {
+        /**
+         * The tag to record the bind variables of SQL.
+         */
+        public static final String DB_TYPE = "db.type";
+        
+        public static final String DB_STATEMENT = "db.statement";
+        
+        public static final String DB_INSTANCE = "db.instance";
+        
+        public static final String DB_BIND_VARIABLES = "db.bind_vars";
+        
+        public static final String COMPONENT = "component";
+        
+        public static final String PEER_HOSTNAME = "peer.hostname";
+        
+        /**
+         * PEER_PORT records the port number of the peer.
+         */
+        public static final String PEER_PORT = "peer.port";
+        
+        
+        /**
+         * The tag to record the connection count.
+         */
+        public static final String CONNECTION_COUNT = "connection.count";
+    }
+}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/ZipkinPluginDefinition.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/ZipkinPluginDefinition.java
new file mode 100644
index 0000000..4fdb765
--- /dev/null
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/ZipkinPluginDefinition.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.agent.plugin.trace.zipkin;
+
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.PluginDefinition;
+
+/**
+ * Zipkin plugin definition.
+ */
+public class ZipkinPluginDefinition extends PluginDefinition {
+    
+    public ZipkinPluginDefinition() {
+        super("zipkin");
+    }
+    
+    @Override
+    protected void define() {
+        registerService(ZipkinTracerService.class);
+        
+        intercept("org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask")
+                .aroundInstanceMethod(ElementMatchers.named("executeCommand"))
+                .implement("org.apache.shardingsphere.agent.plugin.trace.zipkin.advice.CommandExecutorTaskAdvice")
+                .build();
+        intercept("org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine")
+                .aroundInstanceMethod(ElementMatchers.named("parse"))
+                .implement("org.apache.shardingsphere.agent.plugin.trace.zipkin.advice.SQLParserEngineAdvice")
+                .build();
+        intercept("org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback")
+                .aroundInstanceMethod(
+                        ElementMatchers.named("execute")
+                                .and(ElementMatchers.takesArgument(
+                                        0,
+                                        ElementMatchers.named("org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit"))
+                                )
+                )
+                .implement("org.apache.shardingsphere.agent.plugin.trace.zipkin.advice.JDBCExecutorCallbackAdvice")
+                .build();
+    }
+}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/ZipkinTracerService.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/ZipkinTracerService.java
new file mode 100644
index 0000000..d3198f2
--- /dev/null
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/ZipkinTracerService.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.agent.plugin.trace.zipkin;
+
+import brave.Tracing;
+import org.apache.shardingsphere.agent.core.config.AgentConfiguration;
+import org.apache.shardingsphere.agent.core.plugin.Service;
+import org.apache.shardingsphere.agent.core.utils.SingletonHolder;
+import zipkin2.reporter.brave.AsyncZipkinSpanHandler;
+import zipkin2.reporter.okhttp3.OkHttpSender;
+
+/**
+ * Zipkin tracer service.
+ */
+public class ZipkinTracerService implements Service {
+    
+    private AsyncZipkinSpanHandler zipkinSpanHandler;
+    
+    private OkHttpSender sender;
+    
+    private Tracing tracing;
+
+    @Override
+    public void setup() {
+        AgentConfiguration configuration = SingletonHolder.INSTANCE.get(AgentConfiguration.class);
+        AgentConfiguration.TracingConfiguration tracingConfiguration = configuration.getTracing();
+        sender = OkHttpSender.create("http://" + tracingConfiguration.getAgentHost() + ":" + tracingConfiguration.getAgentPort());
+        zipkinSpanHandler = AsyncZipkinSpanHandler.create(sender);
+    }
+
+    @Override
+    public void start() {
+        tracing = Tracing.newBuilder().localServiceName("shardingsphere-agent").addSpanHandler(zipkinSpanHandler).build();
+    }
+
+    @Override
+    public void cleanup() {
+        tracing.close();
+        zipkinSpanHandler.close();
+        sender.close();
+    }
+
+}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/advice/CommandExecutorTaskAdvice.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/advice/CommandExecutorTaskAdvice.java
new file mode 100644
index 0000000..faf974a
--- /dev/null
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/advice/CommandExecutorTaskAdvice.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.agent.plugin.trace.zipkin.advice;
+
+import brave.Span;
+import brave.Tracing;
+import lombok.SneakyThrows;
+import org.apache.shardingsphere.agent.core.plugin.advice.MethodAroundAdvice;
+import org.apache.shardingsphere.agent.core.plugin.advice.MethodInvocationResult;
+import org.apache.shardingsphere.agent.core.plugin.advice.TargetObject;
+import org.apache.shardingsphere.agent.plugin.trace.zipkin.ShardingConstants;
+import org.apache.shardingsphere.infra.executor.kernel.model.ExecutorDataMap;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
+
+import java.lang.reflect.Method;
+
+/**
+ * Command executor task advice.
+ */
+public class CommandExecutorTaskAdvice implements MethodAroundAdvice {
+
+    private static final String OPERATION_NAME = "/ShardingSphere/rootInvoke/";
+
+    @Override
+    public void beforeMethod(final TargetObject target, final Method method, final Object[] args, final MethodInvocationResult result) {
+        Span span = Tracing.currentTracer().newTrace().name(OPERATION_NAME);
+        span.tag(ShardingConstants.Tags.COMPONENT, ShardingConstants.COMPONENT_NAME).kind(Span.Kind.CLIENT)
+                .tag(ShardingConstants.Tags.DB_STATEMENT, ShardingConstants.DB_TYPE_VALUE).start();
+        ExecutorDataMap.getValue().put(ShardingConstants.ROOT_SPAN, span);
+    }
+
+    @SneakyThrows
+    @Override
+    public void afterMethod(final TargetObject target, final Method method, final Object[] args, final MethodInvocationResult result) {
+        BackendConnection connection = (BackendConnection) CommandExecutorTask.class.getDeclaredField("backendConnection").get(target);
+        Span span = (Span) ExecutorDataMap.getValue().remove(ShardingConstants.ROOT_SPAN);
+        span.tag(ShardingConstants.Tags.CONNECTION_COUNT, String.valueOf(connection.getConnectionSize()));
+        span.flush();
+    }
+
+    @Override
+    public void onThrowing(final TargetObject target, final Method method, final Object[] args, final Throwable throwable) {
+        ((Span) ExecutorDataMap.getValue().get(ShardingConstants.ROOT_SPAN)).error(throwable);
+    }
+}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/advice/JDBCExecutorCallbackAdvice.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/advice/JDBCExecutorCallbackAdvice.java
new file mode 100644
index 0000000..9d7cdaf
--- /dev/null
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/advice/JDBCExecutorCallbackAdvice.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.agent.plugin.trace.zipkin.advice;
+
+import brave.Span;
+import brave.Tracing;
+import lombok.SneakyThrows;
+import org.apache.shardingsphere.agent.core.plugin.advice.MethodAroundAdvice;
+import org.apache.shardingsphere.agent.core.plugin.advice.MethodInvocationResult;
+import org.apache.shardingsphere.agent.core.plugin.advice.TargetObject;
+import org.apache.shardingsphere.agent.plugin.trace.zipkin.ShardingConstants;
+import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
+import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback;
+
+import java.lang.reflect.Method;
+import java.sql.DatabaseMetaData;
+import java.util.Map;
+
+/**
+ * JDBC executor callback advice.
+ */
+public class JDBCExecutorCallbackAdvice implements MethodAroundAdvice {
+    
+    private static final String OPERATION_NAME = "/ShardingSphere/executeSQL/";
+    
+    @SneakyThrows
+    @Override
+    public void beforeMethod(final TargetObject target, final Method method, final Object[] args, final MethodInvocationResult result) {
+        final Span root = (Span) ((Map<String, Object>) args[2]).get(ShardingConstants.ROOT_SPAN);
+        if ((boolean) args[1]) {
+            target.setAttachment(Tracing.currentTracer().newChild(root.context()).name(OPERATION_NAME).start());
+        } else {
+            final JDBCExecutionUnit executionUnit = (JDBCExecutionUnit) args[0];
+            final ExecutionUnit unit = executionUnit.getExecutionUnit();
+            Method getMetadataMethod = JDBCExecutorCallback.class.getDeclaredMethod("getDataSourceMetaData", DatabaseMetaData.class);
+            getMetadataMethod.setAccessible(true);
+            DataSourceMetaData metaData = (DataSourceMetaData) getMetadataMethod.invoke(target, new Object[]{executionUnit.getStorageResource().getConnection().getMetaData()});
+            Span span = Tracing.currentTracer().nextSpan().name(OPERATION_NAME);
+            span.tag(ShardingConstants.Tags.COMPONENT, ShardingConstants.COMPONENT_NAME);
+            span.tag(ShardingConstants.Tags.DB_TYPE, ShardingConstants.DB_TYPE_VALUE);
+            span.tag(ShardingConstants.Tags.DB_INSTANCE, unit.getDataSourceName());
+            span.tag(ShardingConstants.Tags.PEER_HOSTNAME, metaData.getHostName());
+            span.tag(ShardingConstants.Tags.PEER_PORT, String.valueOf(metaData.getPort()));
+            span.tag(ShardingConstants.Tags.DB_STATEMENT, unit.getSqlUnit().getSql());
+            span.tag(ShardingConstants.Tags.DB_BIND_VARIABLES, unit.getSqlUnit().getParameters().toString());
+            span.start();
+            target.setAttachment(span);
+        }
+    }
+    
+    @Override
+    public void afterMethod(final TargetObject target, final Method method, final Object[] args, final MethodInvocationResult result) {
+        ((Span) target.getAttachment()).finish();
+    }
+    
+    @Override
+    public void onThrowing(final TargetObject target, final Method method, final Object[] args, final Throwable throwable) {
+        ((Span) target.getAttachment()).error(throwable);
+    }
+}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/advice/SQLParserEngineAdvice.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/advice/SQLParserEngineAdvice.java
new file mode 100644
index 0000000..3059ca5
--- /dev/null
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracers/shardingsphere-agent-tracer-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/trace/zipkin/advice/SQLParserEngineAdvice.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.agent.plugin.trace.zipkin.advice;
+
+import brave.Span;
+import brave.Tracing;
+import brave.propagation.TraceContext;
+import org.apache.shardingsphere.agent.core.plugin.advice.MethodAroundAdvice;
+import org.apache.shardingsphere.agent.core.plugin.advice.MethodInvocationResult;
+import org.apache.shardingsphere.agent.core.plugin.advice.TargetObject;
+import org.apache.shardingsphere.agent.plugin.trace.zipkin.ShardingConstants;
+import org.apache.shardingsphere.infra.executor.kernel.model.ExecutorDataMap;
+
+import java.lang.reflect.Method;
+
+/**
+ * SQL parser engine advice.
+ */
+public class SQLParserEngineAdvice implements MethodAroundAdvice {
+    
+    private static final String OPERATION_NAME = "/ShardingSphere/parseSQL/";
+    
+    @Override
+    public void beforeMethod(final TargetObject target, final Method method, final Object[] args, final MethodInvocationResult result) {
+        TraceContext parentContext = ((Span) ExecutorDataMap.getValue().get(ShardingConstants.ROOT_SPAN)).context();
+        Span span = Tracing.currentTracer().newChild(parentContext).name(OPERATION_NAME);
+        span.tag(ShardingConstants.Tags.COMPONENT, ShardingConstants.COMPONENT_NAME);
+        span.start();
+        target.setAttachment(span);
+    }
+    
+    @Override
+    public void afterMethod(final TargetObject target, final Method method, final Object[] args, final MethodInvocationResult result) {
+        ((Span) target.getAttachment()).finish();
+    }
+    
+    @Override
+    public void onThrowing(final TargetObject target, final Method method, final Object[] args, final Throwable throwable) {
+        ((Span) target.getAttachment()).error(throwable);
+    }
+}