This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-java.git
The following commit(s) were added to refs/heads/main by this push:
new 77c4eb4 Add an agent plugin to support Jackson (#39)
77c4eb4 is described below
commit 77c4eb4edcc774015ee404c27a77a7427c48cf07
Author: 业余布道师 <[email protected]>
AuthorDate: Mon Sep 27 17:25:32 2021 +0800
Add an agent plugin to support Jackson (#39)
---
.github/workflows/plugins-test.0.yaml | 1 +
CHANGES.md | 1 +
.../network/trace/component/ComponentsDefine.java | 2 +
.../fastjson/define/FastjsonInstrumentation.java | 30 ++---
.../optional-plugins/jackson-2.x-plugin/pom.xml | 52 +++++++
.../plugin/jackson/BasicMethodsInterceptor.java | 55 ++++++++
.../apm/plugin/jackson/ReadValueInterceptor.java | 66 +++++++++
.../jackson/WriteValueAsBytesInterceptor.java | 64 +++++++++
.../jackson/WriteValueAsStringInterceptor.java | 64 +++++++++
.../jackson/define/AbstractInstrumentation.java | 80 +++++++++++
.../define/ObjectMapperInstrumentation.java | 56 ++++++++
.../define/ObjectReaderInstrumentation.java | 54 ++++++++
.../define/ObjectWriterInstrumentation.java | 55 ++++++++
.../src/main/resources/skywalking-plugin.def | 19 +++
.../jackson/BasicMethodsInterceptorTest.java | 80 +++++++++++
.../plugin/jackson/ReadValueInterceptorTest.java | 79 +++++++++++
.../jackson/WriteValueAsBytesInterceptorTest.java | 89 ++++++++++++
.../jackson/WriteValueAsStringInterceptorTest.java | 88 ++++++++++++
apm-sniffer/optional-plugins/pom.xml | 1 +
.../setup/service-agent/java-agent/Plugin-list.md | 1 +
docs/en/setup/service-agent/java-agent/README.md | 1 +
.../service-agent/java-agent/Supported-list.md | 1 +
.../scenarios/jackson-scenario/bin/startup.sh | 21 +++
.../jackson-scenario/config/expectedData.yaml | 150 +++++++++++++++++++++
.../scenarios/jackson-scenario/configuration.yml | 24 ++++
test/plugin/scenarios/jackson-scenario/pom.xml | 130 ++++++++++++++++++
.../src/main/assembly/assembly.xml | 41 ++++++
.../apm/testcase/jackson/Application.java | 34 +++++
.../jackson/controller/CaseController.java | 62 +++++++++
.../apm/testcase/jackson/entity/CaseEntity.java | 41 ++++++
.../apm/testcase/jackson/service/CaseService.java | 79 +++++++++++
.../src/main/resources/application.yaml | 23 ++++
.../jackson-scenario/src/main/resources/log4j2.xml | 30 +++++
.../jackson-scenario/support-version.list | 17 +++
34 files changed, 1576 insertions(+), 15 deletions(-)
diff --git a/.github/workflows/plugins-test.0.yaml
b/.github/workflows/plugins-test.0.yaml
index 24fba53..a6692a2 100644
--- a/.github/workflows/plugins-test.0.yaml
+++ b/.github/workflows/plugins-test.0.yaml
@@ -85,6 +85,7 @@ jobs:
- springmvc-reactive-scenario
- springmvc-reactive-devtools-scenario
- fastjson-scenario
+ - jackson-scenario
steps:
- uses: actions/checkout@v2
with:
diff --git a/CHANGES.md b/CHANGES.md
index f5213f7..49c9f6f 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -23,6 +23,7 @@ Release Notes.
* Provide HikariCP database connection pool plugin.
* Fix NumberFormat exception in jdbc-commons plugin when MysqlURLParser parser
jdbcurl
* Provide Alibaba Fastjson parser/generator plugin.
+* Provide Jackson serialization and deserialization plugin.
* Fix a tracing context leak of SpringMVC plugin, when an internal exception
throws due to response can't be found.
* Make GRPC log reporter sharing GRPC channel with other reporters of agent.
Remove config items of `agent.conf`,
`plugin.toolkit.log.grpc.reporter.server_host`,
`plugin.toolkit.log.grpc.reporter.server_port`, and
`plugin.toolkit.log.grpc.reporter.upstream_timeout`.
rename `plugin.toolkit.log.grpc.reporter.max_message_size` to
`log.max_message_size`.
diff --git
a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
index 8f87961..35902c9 100755
---
a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
+++
b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
@@ -213,4 +213,6 @@ public class ComponentsDefine {
public static final OfficialComponent FASTJSON = new
OfficialComponent(117, "Fastjson");
+ public static final OfficialComponent JACKSON = new OfficialComponent(118,
"Jackson");
+
}
diff --git
a/apm-sniffer/optional-plugins/fastjson-1.2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/fastjson/define/FastjsonInstrumentation.java
b/apm-sniffer/optional-plugins/fastjson-1.2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/fastjson/define/FastjsonInstrumentation.java
index 00d23c0..a69a528 100644
---
a/apm-sniffer/optional-plugins/fastjson-1.2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/fastjson/define/FastjsonInstrumentation.java
+++
b/apm-sniffer/optional-plugins/fastjson-1.2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/fastjson/define/FastjsonInstrumentation.java
@@ -43,25 +43,25 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
*/
public class FastjsonInstrumentation extends
ClassStaticMethodsEnhancePluginDefine {
- public static final String ENHANCE_CLASS = "com.alibaba.fastjson.JSON";
+ private static final String ENHANCE_CLASS = "com.alibaba.fastjson.JSON";
- private static final Map<String, String> ENHANCE_METHODS = new
HashMap<String, String>() {
- {
- put("parseArray",
"org.apache.skywalking.apm.plugin.fastjson.ParseArrayInterceptor");
- put("parse",
"org.apache.skywalking.apm.plugin.fastjson.ParseInterceptor");
- put("parseObject",
"org.apache.skywalking.apm.plugin.fastjson.ParseObjectInterceptor");
- put("toJavaObject",
"org.apache.skywalking.apm.plugin.fastjson.ToJavaObjectInterceptor");
- put("toJSONBytes",
"org.apache.skywalking.apm.plugin.fastjson.ToJsonBytesInterceptor");
- put("toJSON",
"org.apache.skywalking.apm.plugin.fastjson.ToJsonInterceptor");
- put("toJSONString",
"org.apache.skywalking.apm.plugin.fastjson.ToJsonStringInterceptor");
- put("writeJSONString",
"org.apache.skywalking.apm.plugin.fastjson.WriteJsonStringInterceptor");
- }
- };
+ private static final Map<String, String> ENHANCE_METHODS = new HashMap<>();
+
+ static {
+ ENHANCE_METHODS.put("parseArray",
"org.apache.skywalking.apm.plugin.fastjson.ParseArrayInterceptor");
+ ENHANCE_METHODS.put("parse",
"org.apache.skywalking.apm.plugin.fastjson.ParseInterceptor");
+ ENHANCE_METHODS.put("parseObject",
"org.apache.skywalking.apm.plugin.fastjson.ParseObjectInterceptor");
+ ENHANCE_METHODS.put("toJavaObject",
"org.apache.skywalking.apm.plugin.fastjson.ToJavaObjectInterceptor");
+ ENHANCE_METHODS.put("toJSONBytes",
"org.apache.skywalking.apm.plugin.fastjson.ToJsonBytesInterceptor");
+ ENHANCE_METHODS.put("toJSON",
"org.apache.skywalking.apm.plugin.fastjson.ToJsonInterceptor");
+ ENHANCE_METHODS.put("toJSONString",
"org.apache.skywalking.apm.plugin.fastjson.ToJsonStringInterceptor");
+ ENHANCE_METHODS.put("writeJSONString",
"org.apache.skywalking.apm.plugin.fastjson.WriteJsonStringInterceptor");
+ }
@Override
public StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() {
- final List<StaticMethodsInterceptPoint> points = new
ArrayList<StaticMethodsInterceptPoint>(ENHANCE_METHODS.size());
+ final List<StaticMethodsInterceptPoint> points = new
ArrayList<>(ENHANCE_METHODS.size());
for (Map.Entry<String, String> entry : ENHANCE_METHODS.entrySet()) {
final StaticMethodsInterceptPoint point = new
StaticMethodsInterceptPoint() {
@@ -83,7 +83,7 @@ public class FastjsonInstrumentation extends
ClassStaticMethodsEnhancePluginDefi
points.add(point);
}
- return points.toArray(new StaticMethodsInterceptPoint[points.size()]);
+ return points.toArray(new StaticMethodsInterceptPoint[0]);
}
@Override
diff --git a/apm-sniffer/optional-plugins/jackson-2.x-plugin/pom.xml
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/pom.xml
new file mode 100644
index 0000000..9323f6a
--- /dev/null
+++ b/apm-sniffer/optional-plugins/jackson-2.x-plugin/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
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>
+ <parent>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>optional-plugins</artifactId>
+ <version>8.8.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>apm-jackson-2.x-plugin</artifactId>
+ <name>jackson-2.x-plugin</name>
+ <packaging>jar</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <jackson.version>2.9.9</jackson.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>${jackson.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>${jackson.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/BasicMethodsInterceptor.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/BasicMethodsInterceptor.java
new file mode 100644
index 0000000..92bb508
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/BasicMethodsInterceptor.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.skywalking.apm.plugin.jackson;
+
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+import java.lang.reflect.Method;
+
+public class BasicMethodsInterceptor implements
InstanceMethodsAroundInterceptor {
+
+ public static final String OPERATION_NAME_JACKSON = "Jackson/";
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[]
allArguments,
+ Class<?>[] argumentsTypes, MethodInterceptResult
result) throws Throwable {
+
+ AbstractSpan span =
ContextManager.createLocalSpan(OPERATION_NAME_JACKSON +
+ method.getDeclaringClass().getSimpleName() + "." +
method.getName());
+ span.setComponent(ComponentsDefine.JACKSON);
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method,
Object[] allArguments,
+ Class<?>[] argumentsTypes, Object ret) throws
Throwable {
+ ContextManager.stopSpan();
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method,
Object[] allArguments,
+ Class<?>[] argumentsTypes, Throwable t) {
+ ContextManager.activeSpan().log(t);
+ }
+}
\ No newline at end of file
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/ReadValueInterceptor.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/ReadValueInterceptor.java
new file mode 100644
index 0000000..3668ed5
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/ReadValueInterceptor.java
@@ -0,0 +1,66 @@
+/*
+ * 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.skywalking.apm.plugin.jackson;
+
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+import java.io.File;
+import java.lang.reflect.Method;
+
+public class ReadValueInterceptor implements InstanceMethodsAroundInterceptor {
+
+ public static final String OPERATION_NAME_JACKSON = "Jackson/";
+ public static final String SPAN_TAG_KEY_LENGTH = "length";
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[]
allArguments,
+ Class<?>[] argumentsTypes, MethodInterceptResult
result) throws Throwable {
+
+ AbstractSpan span =
ContextManager.createLocalSpan(OPERATION_NAME_JACKSON +
+ method.getDeclaringClass().getSimpleName() + "." +
method.getName());
+ span.setComponent(ComponentsDefine.JACKSON);
+
+ if (allArguments[0] instanceof String) {
+ span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH),
Integer.toString(((String) allArguments[0]).length()));
+ } else if (allArguments[0] instanceof byte[]) {
+ span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH),
Integer.toString(((byte[]) allArguments[0]).length));
+ } else if (allArguments[0] instanceof File) {
+ span.tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH), Long.toString(((File)
allArguments[0]).length()));
+ }
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method,
Object[] allArguments,
+ Class<?>[] argumentsTypes, Object ret) throws
Throwable {
+ ContextManager.stopSpan();
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method,
Object[] allArguments,
+ Class<?>[] argumentsTypes, Throwable t) {
+ ContextManager.activeSpan().log(t);
+ }
+}
\ No newline at end of file
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsBytesInterceptor.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsBytesInterceptor.java
new file mode 100644
index 0000000..1d18cd0
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsBytesInterceptor.java
@@ -0,0 +1,64 @@
+/*
+ * 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.skywalking.apm.plugin.jackson;
+
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+import java.lang.reflect.Method;
+
+public class WriteValueAsBytesInterceptor implements
InstanceMethodsAroundInterceptor {
+
+ public static final String OPERATION_NAME_JACKSON = "Jackson/";
+ public static final String SPAN_TAG_KEY_LENGTH = "length";
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[]
allArguments,
+ Class<?>[] argumentsTypes, MethodInterceptResult
result) throws Throwable {
+
+ AbstractSpan span =
ContextManager.createLocalSpan(OPERATION_NAME_JACKSON +
+ method.getDeclaringClass().getSimpleName() + "." +
method.getName());
+ span.setComponent(ComponentsDefine.JACKSON);
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method,
Object[] allArguments,
+ Class<?>[] argumentsTypes, Object ret) throws
Throwable {
+
+ if (!ContextManager.isActive()) {
+ return ret;
+ }
+ if (ret instanceof byte[]) {
+ ContextManager.activeSpan().tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH),
Integer.toString(((byte[]) ret).length));
+ }
+ ContextManager.stopSpan();
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method,
Object[] allArguments,
+ Class<?>[] argumentsTypes, Throwable t) {
+ ContextManager.activeSpan().log(t);
+ }
+}
\ No newline at end of file
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsStringInterceptor.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsStringInterceptor.java
new file mode 100644
index 0000000..9eb2403
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsStringInterceptor.java
@@ -0,0 +1,64 @@
+/*
+ * 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.skywalking.apm.plugin.jackson;
+
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+import java.lang.reflect.Method;
+
+public class WriteValueAsStringInterceptor implements
InstanceMethodsAroundInterceptor {
+
+ public static final String OPERATION_NAME_JACKSON = "Jackson/";
+ public static final String SPAN_TAG_KEY_LENGTH = "length";
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[]
allArguments,
+ Class<?>[] argumentsTypes, MethodInterceptResult
result) throws Throwable {
+
+ AbstractSpan span =
ContextManager.createLocalSpan(OPERATION_NAME_JACKSON +
+ method.getDeclaringClass().getSimpleName() + "." +
method.getName());
+ span.setComponent(ComponentsDefine.JACKSON);
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method,
Object[] allArguments,
+ Class<?>[] argumentsTypes, Object ret) throws
Throwable {
+
+ if (!ContextManager.isActive()) {
+ return ret;
+ }
+ if (ret instanceof String) {
+ ContextManager.activeSpan().tag(Tags.ofKey(SPAN_TAG_KEY_LENGTH),
Integer.toString(((String) ret).length()));
+ }
+ ContextManager.stopSpan();
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method,
Object[] allArguments,
+ Class<?>[] argumentsTypes, Throwable t) {
+ ContextManager.activeSpan().log(t);
+ }
+}
\ No newline at end of file
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/AbstractInstrumentation.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/AbstractInstrumentation.java
new file mode 100644
index 0000000..05e1abb
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/AbstractInstrumentation.java
@@ -0,0 +1,80 @@
+/*
+ * 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.skywalking.apm.plugin.jackson.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+
+/**
+ * Jackson provides a "one stop" solution for json serialization and
deserialization solution
+ * basic requirements.
+ */
+
+public abstract class AbstractInstrumentation extends
ClassInstanceMethodsEnhancePluginDefine {
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints()
{
+
+ final List<InstanceMethodsInterceptPoint> points = new
ArrayList<>(this.enhanceMethods().size());
+
+ for (Map.Entry<String, String> entry :
this.enhanceMethods().entrySet()) {
+ final InstanceMethodsInterceptPoint point = new
InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher<MethodDescription> getMethodsMatcher() {
+ return named(entry.getKey());
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return entry.getValue();
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ };
+ points.add(point);
+ }
+
+ return points.toArray(new InstanceMethodsInterceptPoint[0]);
+ }
+
+ /**
+ * Define the method and interceptor kev/value. method name is key,
interceptor class is value.
+ *
+ * @return enhance methods
+ */
+ protected abstract Map<String, String> enhanceMethods();
+
+}
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/ObjectMapperInstrumentation.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/ObjectMapperInstrumentation.java
new file mode 100644
index 0000000..81b7e79
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/ObjectMapperInstrumentation.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.skywalking.apm.plugin.jackson.define;
+
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Jackson provides a "one stop" solution for json serialization and
deserialization solution
+ * basic requirements.
+ * <p>
+ * ObjectMapper:
writeValue()\writeValueAsString()\writeValueAsBytes()\readValue()
+ */
+
+public class ObjectMapperInstrumentation extends AbstractInstrumentation {
+
+ private static final String ENHANCE_CLASS =
"com.fasterxml.jackson.databind.ObjectMapper";
+
+ private static final Map<String, String> ENHANCE_METHODS = new HashMap<>();
+
+ static {
+ ENHANCE_METHODS.put("writeValue",
"org.apache.skywalking.apm.plugin.jackson.BasicMethodsInterceptor");
+ ENHANCE_METHODS.put("writeValueAsString",
"org.apache.skywalking.apm.plugin.jackson.WriteValueAsStringInterceptor");
+ ENHANCE_METHODS.put("writeValueAsBytes",
"org.apache.skywalking.apm.plugin.jackson.WriteValueAsBytesInterceptor");
+ ENHANCE_METHODS.put("readValue",
"org.apache.skywalking.apm.plugin.jackson.ReadValueInterceptor");
+ }
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return NameMatch.byName(ENHANCE_CLASS);
+ }
+
+ @Override
+ protected Map<String, String> enhanceMethods() {
+ return ENHANCE_METHODS;
+ }
+}
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/ObjectReaderInstrumentation.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/ObjectReaderInstrumentation.java
new file mode 100644
index 0000000..38597b8
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/ObjectReaderInstrumentation.java
@@ -0,0 +1,54 @@
+/*
+ * 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.skywalking.apm.plugin.jackson.define;
+
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Jackson provides a "one stop" solution for json serialization and
deserialization solution
+ * basic requirements.
+ * <p>
+ * ObjectReader: readValue()\readValues()
+ */
+
+public class ObjectReaderInstrumentation extends AbstractInstrumentation {
+
+ private static final String ENHANCE_CLASS =
"com.fasterxml.jackson.databind.ObjectReader";
+
+ private static final Map<String, String> ENHANCE_METHODS = new HashMap<>();
+
+ static {
+ ENHANCE_METHODS.put("readValue",
"org.apache.skywalking.apm.plugin.jackson.ReadValueInterceptor");
+ ENHANCE_METHODS.put("readValues",
"org.apache.skywalking.apm.plugin.jackson.ReadValueInterceptor");
+ }
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return NameMatch.byName(ENHANCE_CLASS);
+ }
+
+ @Override
+ protected Map<String, String> enhanceMethods() {
+ return ENHANCE_METHODS;
+ }
+}
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/ObjectWriterInstrumentation.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/ObjectWriterInstrumentation.java
new file mode 100644
index 0000000..77d9d7d
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jackson/define/ObjectWriterInstrumentation.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.skywalking.apm.plugin.jackson.define;
+
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Jackson provides a "one stop" solution for json serialization and
deserialization solution
+ * basic requirements.
+ * <p>
+ * ObjectWriter: writeValue()\writeValueAsString()\writeValueAsBytes()
+ */
+
+public class ObjectWriterInstrumentation extends AbstractInstrumentation {
+
+ private static final String ENHANCE_CLASS =
"com.fasterxml.jackson.databind.ObjectWriter";
+
+ private static final Map<String, String> ENHANCE_METHODS = new HashMap<>();
+
+ static {
+ ENHANCE_METHODS.put("writeValue",
"org.apache.skywalking.apm.plugin.jackson.BasicMethodsInterceptor");
+ ENHANCE_METHODS.put("writeValueAsString",
"org.apache.skywalking.apm.plugin.jackson.WriteValueAsStringInterceptor");
+ ENHANCE_METHODS.put("writeValueAsBytes",
"org.apache.skywalking.apm.plugin.jackson.WriteValueAsBytesInterceptor");
+ }
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return NameMatch.byName(ENHANCE_CLASS);
+ }
+
+ @Override
+ protected Map<String, String> enhanceMethods() {
+ return ENHANCE_METHODS;
+ }
+}
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/resources/skywalking-plugin.def
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 0000000..0d47432
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,19 @@
+# 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.
+
+jackson-2.x=org.apache.skywalking.apm.plugin.jackson.define.ObjectMapperInstrumentation
+jackson-2.x=org.apache.skywalking.apm.plugin.jackson.define.ObjectReaderInstrumentation
+jackson-2.x=org.apache.skywalking.apm.plugin.jackson.define.ObjectWriterInstrumentation
\ No newline at end of file
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/BasicMethodsInterceptorTest.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/BasicMethodsInterceptorTest.java
new file mode 100644
index 0000000..03285ef
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/BasicMethodsInterceptorTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.skywalking.apm.plugin.jackson;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment;
+import org.apache.skywalking.apm.agent.test.helper.SegmentHelper;
+import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule;
+import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
+import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
+import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(TracingSegmentRunner.class)
+public class BasicMethodsInterceptorTest {
+
+ private BasicMethodsInterceptor basicMethodsInterceptor;
+
+ @SegmentStoragePoint
+ private SegmentStorage segmentStorage;
+
+ @Rule
+ public AgentServiceRule serviceRule = new AgentServiceRule();
+
+ private Object[] arguments;
+
+ private Class[] argumentType;
+
+ @Before
+ public void setUp() {
+ basicMethodsInterceptor = new BasicMethodsInterceptor();
+ arguments = new Object[0];
+ }
+
+ @Test
+ public void testSendMessage() throws Throwable {
+
+ Method method = ObjectMapper.class.getMethod("writeValue", File.class,
Object.class);
+ basicMethodsInterceptor.beforeMethod(null, method, arguments, null,
null);
+ basicMethodsInterceptor.afterMethod(null, method, arguments, null,
null);
+
+ List<TraceSegment> traceSegmentList =
segmentStorage.getTraceSegments();
+ assertThat(traceSegmentList.size(), is(1));
+
+ TraceSegment segment = traceSegmentList.get(0);
+ List<AbstractTracingSpan> spans = SegmentHelper.getSpans(segment);
+ assertThat(spans.size(), is(1));
+ }
+
+}
\ No newline at end of file
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/ReadValueInterceptorTest.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/ReadValueInterceptorTest.java
new file mode 100644
index 0000000..786ee61
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/ReadValueInterceptorTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.skywalking.apm.plugin.jackson;
+
+import com.fasterxml.jackson.databind.ObjectReader;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment;
+import org.apache.skywalking.apm.agent.test.helper.SegmentHelper;
+import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule;
+import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
+import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
+import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(TracingSegmentRunner.class)
+public class ReadValueInterceptorTest {
+
+ private ReadValueInterceptor readValueInterceptor;
+
+ @SegmentStoragePoint
+ private SegmentStorage segmentStorage;
+
+ @Rule
+ public AgentServiceRule serviceRule = new AgentServiceRule();
+
+ private Object[] arguments;
+
+ private Class[] argumentType;
+
+ @Before
+ public void setUp() {
+ readValueInterceptor = new ReadValueInterceptor();
+ arguments = new Object[]{"{\"key\": 123}"};
+ }
+
+ @Test
+ public void testSendMessage() throws Throwable {
+
+ Method method = ObjectReader.class.getMethod("readValue",
String.class);
+ readValueInterceptor.beforeMethod(null, method, arguments, null, null);
+ readValueInterceptor.afterMethod(null, method, arguments, null, null);
+
+ List<TraceSegment> traceSegmentList =
segmentStorage.getTraceSegments();
+ assertThat(traceSegmentList.size(), is(1));
+
+ TraceSegment segment = traceSegmentList.get(0);
+ List<AbstractTracingSpan> spans = SegmentHelper.getSpans(segment);
+ assertThat(spans.size(), is(1));
+ }
+
+}
\ No newline at end of file
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsBytesInterceptorTest.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsBytesInterceptorTest.java
new file mode 100644
index 0000000..e3d8c1f
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsBytesInterceptorTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.skywalking.apm.plugin.jackson;
+
+import com.fasterxml.jackson.databind.ObjectWriter;
+import lombok.Data;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment;
+import org.apache.skywalking.apm.agent.test.helper.SegmentHelper;
+import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule;
+import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
+import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
+import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(TracingSegmentRunner.class)
+public class WriteValueAsBytesInterceptorTest {
+
+ private WriteValueAsBytesInterceptor writeValueAsBytesInterceptor;
+
+ @SegmentStoragePoint
+ private SegmentStorage segmentStorage;
+
+ @Rule
+ public AgentServiceRule serviceRule = new AgentServiceRule();
+
+ private Object[] arguments;
+
+ private Object result;
+
+ private Class[] argumentType;
+
+ @Data
+ private class TestBean {
+ private int key;
+ }
+
+ @Before
+ public void setUp() {
+ writeValueAsBytesInterceptor = new WriteValueAsBytesInterceptor();
+ arguments = new Object[]{new TestBean()};
+ result = new byte[0];
+ }
+
+ @Test
+ public void testSendMessage() throws Throwable {
+
+ Method method = ObjectWriter.class.getMethod("writeValueAsBytes",
Object.class);
+
+ writeValueAsBytesInterceptor.beforeMethod(null, method, arguments,
null, null);
+ writeValueAsBytesInterceptor.afterMethod(null, method, arguments,
null, result);
+
+ List<TraceSegment> traceSegmentList =
segmentStorage.getTraceSegments();
+ assertThat(traceSegmentList.size(), is(1));
+
+ TraceSegment segment = traceSegmentList.get(0);
+ List<AbstractTracingSpan> spans = SegmentHelper.getSpans(segment);
+ assertThat(spans.size(), is(1));
+ }
+
+}
\ No newline at end of file
diff --git
a/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsStringInterceptorTest.java
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsStringInterceptorTest.java
new file mode 100644
index 0000000..3464f2e
--- /dev/null
+++
b/apm-sniffer/optional-plugins/jackson-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jackson/WriteValueAsStringInterceptorTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.skywalking.apm.plugin.jackson;
+
+import com.fasterxml.jackson.databind.ObjectWriter;
+import lombok.Data;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment;
+import org.apache.skywalking.apm.agent.test.helper.SegmentHelper;
+import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule;
+import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
+import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
+import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(TracingSegmentRunner.class)
+public class WriteValueAsStringInterceptorTest {
+
+ private WriteValueAsStringInterceptor writeValueAsStringInterceptor;
+
+ @SegmentStoragePoint
+ private SegmentStorage segmentStorage;
+
+ @Rule
+ public AgentServiceRule serviceRule = new AgentServiceRule();
+
+ private Object[] arguments;
+
+ private Object result;
+
+ private Class[] argumentType;
+
+ @Data
+ private class TestBean {
+ private int key;
+ }
+
+ @Before
+ public void setUp() {
+ writeValueAsStringInterceptor = new WriteValueAsStringInterceptor();
+ arguments = new Object[]{new TestBean()};
+ result = "{\"key\": 123}";
+ }
+
+ @Test
+ public void testSendMessage() throws Throwable {
+
+ Method method = ObjectWriter.class.getMethod("writeValueAsString",
Object.class);
+ writeValueAsStringInterceptor.beforeMethod(null, method, arguments,
null, null);
+ writeValueAsStringInterceptor.afterMethod(null, method, arguments,
null, result);
+
+ List<TraceSegment> traceSegmentList =
segmentStorage.getTraceSegments();
+ assertThat(traceSegmentList.size(), is(1));
+
+ TraceSegment segment = traceSegmentList.get(0);
+ List<AbstractTracingSpan> spans = SegmentHelper.getSpans(segment);
+ assertThat(spans.size(), is(1));
+ }
+
+}
\ No newline at end of file
diff --git a/apm-sniffer/optional-plugins/pom.xml
b/apm-sniffer/optional-plugins/pom.xml
index 8bef019..896494d 100644
--- a/apm-sniffer/optional-plugins/pom.xml
+++ b/apm-sniffer/optional-plugins/pom.xml
@@ -54,6 +54,7 @@
<module>ehcache-2.x-plugin</module>
<module>guava-cache-plugin</module>
<module>fastjson-1.2.x-plugin</module>
+ <module>jackson-2.x-plugin</module>
</modules>
<dependencies>
diff --git a/docs/en/setup/service-agent/java-agent/Plugin-list.md
b/docs/en/setup/service-agent/java-agent/Plugin-list.md
index 44ad25a..81a09cc 100644
--- a/docs/en/setup/service-agent/java-agent/Plugin-list.md
+++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md
@@ -35,6 +35,7 @@
- httpclient-5.x
- hystrix-1.x
- influxdb-2.x
+- jackson-2.x
- jdk-http-plugin
- jdk-threading-plugin
- jedis-2.x
diff --git a/docs/en/setup/service-agent/java-agent/README.md
b/docs/en/setup/service-agent/java-agent/README.md
index 8f60dcb..1d40bcc 100755
--- a/docs/en/setup/service-agent/java-agent/README.md
+++ b/docs/en/setup/service-agent/java-agent/README.md
@@ -88,6 +88,7 @@ Now, we have the following known optional plugins.
* Plugin of ehcache-2.x in the optional plugin folder. The reason for being an
optional plugin is, this plugin enhanced cache framework, generates large
number of local spans, which have a potential performance impact.
* Plugin of guava-cache in the optional plugin folder. The reason for being an
optional plugin is, this plugin enhanced cache framework, generates large
number of local spans, which have a potential performance impact.
* Plugin of fastjson serialization lib in optional plugin folder.
+* Plugin of jackson serialization lib in optional plugin folder.
## Bootstrap class plugins
All bootstrap plugins are optional, due to unexpected risk. Bootstrap plugins
are provided in `bootstrap-plugins` folder.
diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md
b/docs/en/setup/service-agent/java-agent/Supported-list.md
index c7bf9f9..a35263f 100644
--- a/docs/en/setup/service-agent/java-agent/Supported-list.md
+++ b/docs/en/setup/service-agent/java-agent/Supported-list.md
@@ -107,6 +107,7 @@ metrics based on the tracing data.
* JSON
* [GSON](https://github.com/google/gson) 2.8.x (Optional²)
* [Fastjson](https://github.com/alibaba/fastjson) 1.2.x (Optional²)
+ * [Jackson](https://github.com/FasterXML/jackson) 2.x (Optional²)
* Vert.x Ecosystem
* Vert.x Eventbus 3.2+
* Vert.x Web 3.x
diff --git a/test/plugin/scenarios/jackson-scenario/bin/startup.sh
b/test/plugin/scenarios/jackson-scenario/bin/startup.sh
new file mode 100644
index 0000000..cee7ddb
--- /dev/null
+++ b/test/plugin/scenarios/jackson-scenario/bin/startup.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# 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.
+
+home="$(cd "$(dirname $0)"; pwd)"
+
+java -jar ${agent_opts} ${home}/../libs/jackson-scenario.jar &
\ No newline at end of file
diff --git a/test/plugin/scenarios/jackson-scenario/config/expectedData.yaml
b/test/plugin/scenarios/jackson-scenario/config/expectedData.yaml
new file mode 100644
index 0000000..42e359c
--- /dev/null
+++ b/test/plugin/scenarios/jackson-scenario/config/expectedData.yaml
@@ -0,0 +1,150 @@
+# 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.
+segmentItems:
+- serviceName: jackson-scenario
+ segmentSize: ge 2
+ segments:
+ - segmentId: nq 0
+ spans:
+ - operationName: Jackson/ObjectMapper.writeValue
+ parentSpanId: 0
+ spanId: 1
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 118
+ isError: false
+ spanType: Local
+ peer: ''
+ - operationName: Jackson/ObjectMapper.writeValueAsString
+ parentSpanId: 0
+ spanId: 2
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 118
+ isError: false
+ spanType: Local
+ peer: ''
+ tags:
+ - {key: length, value: '20'}
+ - operationName: Jackson/ObjectMapper.writeValueAsBytes
+ parentSpanId: 0
+ spanId: 3
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 118
+ isError: false
+ spanType: Local
+ peer: ''
+ tags:
+ - {key: length, value: '20'}
+ - operationName: Jackson/ObjectMapper.readValue
+ parentSpanId: 0
+ spanId: 4
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 118
+ isError: false
+ spanType: Local
+ peer: ''
+ tags:
+ - {key: length, value: '26'}
+ - operationName: Jackson/ObjectReader.readValue
+ parentSpanId: 0
+ spanId: 5
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 118
+ isError: false
+ spanType: Local
+ peer: ''
+ tags:
+ - {key: length, value: '26'}
+ - operationName: Jackson/ObjectReader.readValue
+ parentSpanId: 0
+ spanId: 6
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 118
+ isError: false
+ spanType: Local
+ peer: ''
+ tags:
+ - {key: length, value: '26'}
+ - operationName: Jackson/ObjectReader.readValues
+ parentSpanId: 0
+ spanId: 7
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 118
+ isError: false
+ spanType: Local
+ peer: ''
+ tags:
+ - {key: length, value: '26'}
+ - operationName: Jackson/ObjectWriter.writeValue
+ parentSpanId: 0
+ spanId: 8
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 118
+ isError: false
+ spanType: Local
+ peer: ''
+ - operationName: Jackson/ObjectWriter.writeValueAsString
+ parentSpanId: 0
+ spanId: 9
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 118
+ isError: false
+ spanType: Local
+ peer: ''
+ tags:
+ - {key: length, value: '20'}
+ - operationName: Jackson/ObjectWriter.writeValueAsBytes
+ parentSpanId: 0
+ spanId: 10
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 118
+ isError: false
+ spanType: Local
+ peer: ''
+ tags:
+ - {key: length, value: '20'}
+ - operationName: GET:/jackson-scenario/case/jackson-scenario
+ parentSpanId: -1
+ spanId: 0
+ spanLayer: Http
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 1
+ isError: false
+ spanType: Entry
+ peer: ''
+ tags:
+ - {key: url, value:
'http://localhost:8080/jackson-scenario/case/jackson-scenario'}
+ - {key: http.method, value: GET}
diff --git a/test/plugin/scenarios/jackson-scenario/configuration.yml
b/test/plugin/scenarios/jackson-scenario/configuration.yml
new file mode 100644
index 0000000..5a29caa
--- /dev/null
+++ b/test/plugin/scenarios/jackson-scenario/configuration.yml
@@ -0,0 +1,24 @@
+# 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.
+
+type: jvm
+entryService: http://localhost:8080/jackson-scenario/case/jackson-scenario
+healthCheck: http://localhost:8080/jackson-scenario/case/healthCheck
+startScript: ./bin/startup.sh
+runningMode: with_optional
+withPlugins: apm-jackson-2.x-plugin-*.jar
+environment:
+dependencies:
diff --git a/test/plugin/scenarios/jackson-scenario/pom.xml
b/test/plugin/scenarios/jackson-scenario/pom.xml
new file mode 100644
index 0000000..3baf356
--- /dev/null
+++ b/test/plugin/scenarios/jackson-scenario/pom.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ 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">
+
+ <groupId>org.apache.skywalking.apm.testcase</groupId>
+ <artifactId>jackson-scenario</artifactId>
+ <version>1.0.0</version>
+ <packaging>jar</packaging>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <spring-boot-version>2.1.6.RELEASE</spring-boot-version>
+ <test.framework.version>2.9.9</test.framework.version>
+ <docker.image.version>${test.framework.version}</docker.image.version>
+ <log4j.version>2.6.2</log4j.version>
+ <spring.version>4.3.8.RELEASE</spring.version>
+ </properties>
+
+ <name>skywalking-jackson-scenario</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${spring-boot-version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-log4j2</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>${test.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>${test.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>${test.framework.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>jackson-scenario</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${compiler.version}</source>
+ <target>${compiler.version}</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assemble</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+
<descriptor>src/main/assembly/assembly.xml</descriptor>
+ </descriptors>
+ <outputDirectory>./target/</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git
a/test/plugin/scenarios/jackson-scenario/src/main/assembly/assembly.xml
b/test/plugin/scenarios/jackson-scenario/src/main/assembly/assembly.xml
new file mode 100644
index 0000000..4228363
--- /dev/null
+++ b/test/plugin/scenarios/jackson-scenario/src/main/assembly/assembly.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ -->
+<assembly
+
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <fileSets>
+ <fileSet>
+ <directory>./bin</directory>
+ <fileMode>0775</fileMode>
+ </fileSet>
+ </fileSets>
+
+ <files>
+ <file>
+ <source>${project.build.directory}/jackson-scenario.jar</source>
+ <outputDirectory>./libs</outputDirectory>
+ <fileMode>0775</fileMode>
+ </file>
+ </files>
+</assembly>
diff --git
a/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/Application.java
b/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/Application.java
new file mode 100644
index 0000000..027431d
--- /dev/null
+++
b/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/Application.java
@@ -0,0 +1,34 @@
+/*
+ * 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.skywalking.apm.testcase.jackson;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ try {
+ SpringApplication.run(Application.class, args);
+ } catch (Exception e) {
+ // Never do this
+ }
+ }
+}
diff --git
a/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/controller/CaseController.java
b/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/controller/CaseController.java
new file mode 100644
index 0000000..423d2ce
--- /dev/null
+++
b/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/controller/CaseController.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.skywalking.apm.testcase.jackson.controller;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.skywalking.apm.testcase.jackson.service.CaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.io.IOException;
+
+@RestController
+@RequestMapping("/case")
+public class CaseController {
+
+ @Autowired
+ CaseService caseService;
+
+ private static final Logger LOGGER =
LogManager.getLogger(CaseController.class);
+
+ private static final String SUCCESS = "Success";
+
+ @RequestMapping("/jackson-scenario")
+ @ResponseBody
+ public String testcase() throws IOException {
+ try {
+ caseService.mapperCase();
+ caseService.readerCase();
+ caseService.writerCase();
+ } catch (IOException e) {
+ LOGGER.error("Failed to parse json.", e);
+ throw e;
+ }
+ return SUCCESS;
+ }
+
+ @RequestMapping("/healthCheck")
+ @ResponseBody
+ public String healthCheck() {
+ return SUCCESS;
+ }
+
+}
diff --git
a/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/entity/CaseEntity.java
b/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/entity/CaseEntity.java
new file mode 100644
index 0000000..fb13e4a
--- /dev/null
+++
b/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/entity/CaseEntity.java
@@ -0,0 +1,41 @@
+/*
+ * 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.skywalking.apm.testcase.jackson.entity;
+
+public class CaseEntity {
+
+ private int key;
+ private String msg;
+
+ public int getKey() {
+ return key;
+ }
+
+ public void setKey(int key) {
+ this.key = key;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+}
diff --git
a/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/service/CaseService.java
b/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/service/CaseService.java
new file mode 100644
index 0000000..c454533
--- /dev/null
+++
b/test/plugin/scenarios/jackson-scenario/src/main/java/org/apache/skywalking/apm/testcase/jackson/service/CaseService.java
@@ -0,0 +1,79 @@
+/*
+ * 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.skywalking.apm.testcase.jackson.service;
+
+import com.fasterxml.jackson.databind.MappingIterator;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import org.apache.skywalking.apm.testcase.jackson.entity.CaseEntity;
+import org.springframework.stereotype.Service;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+@Service
+public class CaseService {
+
+ public void mapperCase() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ CaseEntity entity = new CaseEntity();
+ mapper.writeValue(out, entity);
+
+ Object jsonStr = mapper.writeValueAsString(entity);
+ assert jsonStr instanceof String;
+ Object jsonByte = mapper.writeValueAsBytes(entity);
+ assert jsonByte instanceof byte[];
+
+ String jsonString = "{\"key\":123, \"msg\":\"test\" }";
+ Object jsonObj = mapper.readValue(jsonString, CaseEntity.class);
+ assert jsonObj instanceof CaseEntity;
+ }
+
+ public void readerCase() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectReader reader = mapper.readerFor(CaseEntity.class);
+
+ String jsonString = "{\"key\":123, \"msg\":\"test\" }";
+ byte[] jsonBytes = jsonString.getBytes();
+
+ Object jsonObj1 = reader.readValue(jsonString);
+ assert jsonObj1 instanceof CaseEntity;
+ Object jsonObj2 = reader.readValue(jsonBytes);
+ assert jsonObj2 instanceof CaseEntity;
+ Object jsonObj3 = reader.readValues(jsonString);
+ assert jsonObj3 instanceof MappingIterator;
+ }
+
+ public void writerCase() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectWriter writer = mapper.writerFor(CaseEntity.class);
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ CaseEntity entity = new CaseEntity();
+ writer.writeValue(out, entity);
+
+ Object jsonStr = writer.writeValueAsString(entity);
+ assert jsonStr instanceof String;
+ Object jsonByte = writer.writeValueAsBytes(entity);
+ assert jsonByte instanceof byte[];
+ }
+}
diff --git
a/test/plugin/scenarios/jackson-scenario/src/main/resources/application.yaml
b/test/plugin/scenarios/jackson-scenario/src/main/resources/application.yaml
new file mode 100644
index 0000000..60ac334
--- /dev/null
+++ b/test/plugin/scenarios/jackson-scenario/src/main/resources/application.yaml
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+#
+server:
+ port: 8080
+ servlet:
+ context-path: /jackson-scenario
+logging:
+ config: classpath:log4j2.xml
\ No newline at end of file
diff --git
a/test/plugin/scenarios/jackson-scenario/src/main/resources/log4j2.xml
b/test/plugin/scenarios/jackson-scenario/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..9849ed5
--- /dev/null
+++ b/test/plugin/scenarios/jackson-scenario/src/main/resources/log4j2.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ -->
+<Configuration status="WARN">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_ERR">
+ <PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd
HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="WARN">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
diff --git a/test/plugin/scenarios/jackson-scenario/support-version.list
b/test/plugin/scenarios/jackson-scenario/support-version.list
new file mode 100644
index 0000000..8ab826a
--- /dev/null
+++ b/test/plugin/scenarios/jackson-scenario/support-version.list
@@ -0,0 +1,17 @@
+# 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.
+
+2.9.9