Skip to content

Add an agent plugin to support Jackson#39

Merged
wu-sheng merged 18 commits intoapache:mainfrom
VictorZeng:jackson-plugin
Sep 27, 2021
Merged

Add an agent plugin to support Jackson#39
wu-sheng merged 18 commits intoapache:mainfrom
VictorZeng:jackson-plugin

Conversation

@VictorZeng
Copy link
Contributor

Add an agent plugin to support Jackson

@wu-sheng wu-sheng added this to the 8.8.0 milestone Sep 27, 2021
@wu-sheng wu-sheng added enhancement New feature or request plugin labels Sep 27, 2021
Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the comments inline, I'd also like to discuss whether we should also include part of the JSON string / bytes in the trace, for example, collect the first 64 bytes as a tag content and the 64 is configurable.

Currently we only have the time cost in (de)serializing and the length of the content, but it makes little sense that we don't know what the content is when the time cost is too long, including part of the content might give the users some hints what content makes the JSON lib slower.

VictorZeng and others added 3 commits September 27, 2021 11:14
…org/apache/skywalking/apm/plugin/jackson/define/ObjectMapperInstrumentation.java

Co-authored-by: kezhenxu94 <kezhenxu94@apache.org>
…org/apache/skywalking/apm/plugin/jackson/define/AbstractInstrumentation.java

Co-authored-by: kezhenxu94 <kezhenxu94@apache.org>
…org/apache/skywalking/apm/plugin/jackson/define/AbstractInstrumentation.java

Co-authored-by: kezhenxu94 <kezhenxu94@apache.org>
@wu-sheng
Copy link
Member

Apart from the comments inline, I'd also like to discuss whether we should also include part of the JSON string / bytes in the trace, for example, collect the first 64 bytes as a tag content and the 64 is configurable.

Currently we only have the time cost in (de)serializing and the length of the content, but it makes little sense that we don't know what the content is when the time cost is too long, including part of the content might give the users some hints what content makes the JSON lib slower.

Agree, collecting content is a risk. I prefer we don't do this.

@VictorZeng
Copy link
Contributor Author

Apart from the comments inline, I'd also like to discuss whether we should also include part of the JSON string / bytes in the trace, for example, collect the first 64 bytes as a tag content and the 64 is configurable.
Currently we only have the time cost in (de)serializing and the length of the content, but it makes little sense that we don't know what the content is when the time cost is too long, including part of the content might give the users some hints what content makes the JSON lib slower.

Agree, collecting content is a risk. I prefer we don't do this.

I think that providing JSON length can satisfy most user scenarios. It is not recommended to collect JSON content.

@VictorZeng
Copy link
Contributor Author

@kezhenxu94 use the guava ImmutableMap is a good idea, but failed the checkstyle.

@kezhenxu94
Copy link
Member

@kezhenxu94 use the guava ImmutableMap is a good idea, but failed the checkstyle.

ok. We need some adjustments of the check style settings

@VictorZeng
Copy link
Contributor Author

@kezhenxu94 use the ImmutableMap , must package the guava dependency with plugin jar together. otherwise:
Caused by: java.lang.ClassNotFoundException: Can't find com.google.common.collect.ImmutableMap

Is it necessary to do this?

@kezhenxu94
Copy link
Member

@kezhenxu94 use the ImmutableMap , must package the guava dependency with plugin jar together. otherwise:

Caused by: java.lang.ClassNotFoundException: Can't find com.google.common.collect.ImmutableMap

Is it necessary to do this?

I think guava is bundled with agent core already

@VictorZeng
Copy link
Contributor Author

VictorZeng commented Sep 27, 2021

@kezhenxu94 use the ImmutableMap , must package the guava dependency with plugin jar together. otherwise:
Caused by: java.lang.ClassNotFoundException: Can't find com.google.common.collect.ImmutableMap
Is it necessary to do this?

I think guava is bundled with agent core already

It doesn't look like this now. the apm-agent-core pom.xml guava in <dependencyManagement>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>
            ......
    </dependencyManagement>

and the apm-sdk-plugin and optional-plugins module pom,xml dependency apm-agent-core scope is provided

        <dependency>
            <groupId>org.apache.skywalking</groupId>
            <artifactId>apm-agent-core</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>

@wu-sheng
Copy link
Member

Using this 3rd party APIs, AFAIK, you need to shade. This dependency is there, but indirectly(gRPC depending on it) and shaded in the runtime.
Do we really need to make things this complex? Initializing ENHANCE_METHODS in constructor and use it should be good enough, right?

@VictorZeng
Copy link
Contributor Author

Using this 3rd party APIs, AFAIK, you need to shade. This dependency is there, but indirectly(gRPC depending on it) and shaded in the runtime.
Do we really need to make things this complex? Initializing ENHANCE_METHODS in constructor and use it should be good enough, right?

I noticed this, the source code shaded in org.apache.skywalking.apm.dependencies.*
I think init the ENHANCE_METHODS in constructor is a good idea.

@wu-sheng
Copy link
Member

Plugin default class loader is singleton and wouldn't be GC. Any new class file loaded will be a load for JVM memory permanently. Let's try to keep plugin codes as simple as possible.

@VictorZeng
Copy link
Contributor Author

Plugin default class loader is singleton and wouldn't be GC. Any new class file loaded will be a load for JVM memory permanently. Let's try to keep plugin codes as simple as possible.

Use guava ImmutableMap is a better way, I think I can try to shade it.

@kezhenxu94
Copy link
Member

@kezhenxu94 use the ImmutableMap , must package the guava dependency with plugin jar together. otherwise:
Caused by: java.lang.ClassNotFoundException: Can't find com.google.common.collect.ImmutableMap
Is it necessary to do this?

I think guava is bundled with agent core already

OK I remember it wrong, what is bundled is GSON dependency. But the idea is not to create too many anonymous inner classes, initializing the map in constructor is also good to me

@VictorZeng
Copy link
Contributor Author

@wu-sheng @kezhenxu94 How about init ENHANCE_METHODS in static method block?

@kezhenxu94
Copy link
Member

@wu-sheng @kezhenxu94 How about init ENHANCE_METHODS in static method block?

Okay to me

@VictorZeng
Copy link
Contributor Author

@wu-sheng @kezhenxu94 How about init ENHANCE_METHODS in static method block?

Okay to me

Thank u.

@VictorZeng
Copy link
Contributor Author

@kezhenxu94 elasticjob-3.x-scenario health check failed, it runs successfully on my local.

+ status=0
+ [[ 0 == 0 ]]
+ [[ -z '' ]]
+ rm -rf /home/skywalking-java/test/plugin/workspace/elasticjob-3.x-scenario/3.0.0
+ num_of_testcases=1
+ echo -e '\033[33melasticjob-3.x-scenario has already sumbitted\033[0m'
elasticjob-3.x-scenario has already sumbitted
+ exitAndClean 0
++ date +%s
+ elapsed=404
+ [[ 0 -eq 1 ]]
+ printf 'Scenarios: elasticjob-3.x-scenario, Testcases: 1, Elapsed: %02d:%02d:%02d \n' 0 6 44
Scenarios: elasticjob-3.x-scenario, Testcases: 1, Elapsed: 00:06:44 
+ exit 0

@wu-sheng wu-sheng requested a review from kezhenxu94 September 27, 2021 09:12
Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @VictorZeng . One nit: it seems that you didn't import our code style settings, the new files still don't respect to the code styles, please consider import our code style settings if you are going to contribute later

@VictorZeng
Copy link
Contributor Author

Thank you @VictorZeng . One nit: it seems that you didn't import our code style settings, the new files still don't respect to the code styles, please consider import our code style settings if you are going to contribute later

Thank you for review, I will import the checkstyle.

@wu-sheng wu-sheng merged commit 77c4eb4 into apache:main Sep 27, 2021
@VictorZeng VictorZeng deleted the jackson-plugin branch September 27, 2021 09:26
wu-sheng added a commit that referenced this pull request Oct 31, 2021
* main: (28 commits)
  fix release doc (#61)
  Support Jedis' Transaction and fix duplicated enhancement (#57)
  Initialize 8.9.0 iteration (#59)
  Polish release shell and doc. (#58)
  fix rocketmq message header properties garbled characters issue (#54)
  Fix netty-socketio plugin test failure (#56)
  Add okhttp2.x plugin (#49)
  add e2e test for kafka transporter (#42)
  Fix version badge (#53)
  Add JDK17 supported declaration. (#52)
  Fix instrumentation v2 API doesn't work for constructor instrumentation. (#51)
  Add kylin jdbc plugin (#45)
  Fix version compatibility for JSON-RPC4J Plugin (#50)
  Feature add clickhouse jdbc plugin (#41)
  Update menu.yml (#48)
  Fix format. (#47)
  Add new menu for the document (#46)
  Doc: Update setup agent in kubernetes from 'containers' to 'initContainers'. (#44)
  The httpasyncclient-4.x-plugin does not take effect every time. (#40)
  Add an agent plugin to support Jackson (#39)
  ...

# Conflicts:
#	.github/workflows/plugins-test.3.yaml
#	CHANGES.md
#	docs/en/setup/service-agent/java-agent/README.md
#	docs/menu.yml
GuoHaoZai pushed a commit to GuoHaoZai/skywalking-java that referenced this pull request Apr 24, 2025
Co-authored-by: Evan <evanljp@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants