Skip to content

Commit

Permalink
Upgrade nats plugin to expand support to 2.16.5 (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
pg-yang authored Jul 27, 2024
1 parent 92b09c9 commit 24ec663
Show file tree
Hide file tree
Showing 46 changed files with 69 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/plugins-test.3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- vertx-web-3.6plus-scenario
- mariadb-scenario
- micronaut-http-scenario
- nats-2.14.x-2.15.x-scenario
- nats-2.14.x-2.16.5-scenario
- quasar-scenario
- baidu-brpc-scenario
- baidu-brpc-3.x-scenario
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release Notes.
9.4.0
------------------

* Upgrade nats plugin to support 2.16.5


All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/222?closed=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<modelVersion>4.0.0</modelVersion>

<artifactId>nats-2.14.x-2.15.x-plugin</artifactId>
<artifactId>nats-2.14.x-2.16.5-plugin</artifactId>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.nats.client.define;

import java.util.Collections;
import java.util.List;
import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;

import static net.bytebuddy.matcher.ElementMatchers.named;

public abstract class AbstractWitnessInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {

/*
* Currently, we only support 2.14.x-2.16.5, as there is no proper way and opportunity
* to change the message header and re-calculate the message length for 2.16.5+ yet.
* This method prevents users from applying this plugin to unsupported versions,
* which may cause unknown errors.
* For more information: https://github.com/apache/skywalking/discussions/11650
*/
@Override
protected List<WitnessMethod> witnessMethods() {
return Collections.singletonList(new WitnessMethod(
"io.nats.client.impl.NatsMessage",
named("calculateIfDirty")
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
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 org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;

public class NatsConnectionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
public class NatsConnectionInstrumentation extends AbstractWitnessInstrumentation {

private static final String ENHANCE_CLASS = "io.nats.client.impl.NatsConnection";

Expand Down Expand Up @@ -82,4 +81,4 @@ public boolean isOverrideArgs() {
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
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 org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;

public class NatsConnectionWriterInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
public class NatsConnectionWriterInstrumentation extends AbstractWitnessInstrumentation {

private static final String ENHANCE_CLASS = "io.nats.client.impl.NatsConnectionWriter";
private static final String PUBLISH_INTERCEPTOR_CLASS_NAME = "org.apache.skywalking.apm.plugin.nats.client.WriterSendMessageBatchInterceptor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
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 org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;

public class NatsJetStreamInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
public class NatsJetStreamInstrumentation extends AbstractWitnessInstrumentation {

private static final String ENHANCE_CLASS = "io.nats.client.impl.NatsJetStream";
private static final String CREATE_SUB_INTERCEPTOR = "org.apache.skywalking.apm.plugin.nats.client.CreateSubInterceptor";
Expand Down Expand Up @@ -78,4 +77,4 @@ public boolean isOverrideArgs() {
};
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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 org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;

import static net.bytebuddy.matcher.ElementMatchers.named;
Expand All @@ -35,7 +34,7 @@
*
* BTW , ACK is done by publishing a message , So we needn't enhance ACK method
*/
public class NatsMessageInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
public class NatsMessageInstrumentation extends AbstractWitnessInstrumentation {

private static final String ENHANCE_CLASS = "io.nats.client.impl.NatsMessage";
private static final String PUBLISH_INTERCEPTOR = "org.apache.skywalking.apm.plugin.nats.client.NatsMessageInterceptor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
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 org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;

public class NatsSubscriptionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
public class NatsSubscriptionInstrumentation extends AbstractWitnessInstrumentation {

private static final String ENHANCE_CLASS = "io.nats.client.impl.NatsSubscription";
private static final String NEXT_MSG_INTERCEPTOR = "org.apache.skywalking.apm.plugin.nats.client.SubscriptionNextMsgInterceptor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.NatsMessageInstrumentation
nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.NatsConnectionInstrumentation
nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.NatsConnectionWriterInstrumentation
nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.NatsSubscriptionInstrumentation
nats-client-2.14.x-2.15.x=org.apache.skywalking.apm.plugin.nats.client.define.NatsJetStreamInstrumentation
nats-client-2.14.x-2.16.5=org.apache.skywalking.apm.plugin.nats.client.define.NatsMessageInstrumentation
nats-client-2.14.x-2.16.5=org.apache.skywalking.apm.plugin.nats.client.define.NatsConnectionInstrumentation
nats-client-2.14.x-2.16.5=org.apache.skywalking.apm.plugin.nats.client.define.NatsConnectionWriterInstrumentation
nats-client-2.14.x-2.16.5=org.apache.skywalking.apm.plugin.nats.client.define.NatsSubscriptionInstrumentation
nats-client-2.14.x-2.16.5=org.apache.skywalking.apm.plugin.nats.client.define.NatsJetStreamInstrumentation
2 changes: 1 addition & 1 deletion apm-sniffer/apm-sdk-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<module>guava-eventbus-plugin</module>
<module>hutool-plugins</module>
<module>micronaut-plugins</module>
<module>nats-2.14.x-2.15.x-plugin</module>
<module>nats-2.14.x-2.16.5-plugin</module>
<module>jedis-plugins</module>
<module>apm-armeria-plugins</module>
<module>jetty-thread-pool-plugin</module>
Expand Down
4 changes: 2 additions & 2 deletions docs/en/setup/service-agent/java-agent/Plugin-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
- hutool-http-5.x
- micronaut-http-client-3.2.x-3.6.x
- micronaut-http-server-3.2.x-3.6.x
- nats-client-2.14.x-2.15.x
- nats-client-2.14.x-2.16.5
- impala-jdbc-2.6.x
- jdk-forkjoinpool-plugin
- jetty-thread-pool
Expand All @@ -178,4 +178,4 @@
- spring-webflux-6.x-webclient
- activemq-artemis-jakarta-client-2.x
- c3p0-0.9.x
- solon-2.x
- solon-2.x
2 changes: 1 addition & 1 deletion docs/en/setup/service-agent/java-agent/Supported-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ metrics based on the tracing data.
* [ActiveMQ](https://github.com/apache/activemq) 5.10.0 -> 5.15.4
* [RabbitMQ](https://www.rabbitmq.com/) 3.x-> 5.x
* [Pulsar](http://pulsar.apache.org) 2.2.x -> 2.9.x
* [NATS](https://github.com/nats-io/nats.java) 2.14.x -> 2.15.x
* [NATS](https://github.com/nats-io/nats.java) 2.14.x -> 2.16.5
* [ActiveMQ-Artemis](https://github.com/apache/activemq) 2.30.0 -> 2.31.2
* Aliyun ONS 1.x (Optional¹)
* NoSQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ home="$(cd "$(dirname $0)"; pwd)"
java -jar ${agent_opts} -Dserver.port=8080 \
-Dskywalking.agent.service_name=scenario-8080- \
-Dnats.server=nats-server \
${home}/../libs/nats-2.14.x-2.15.x-scenario.jar &
${home}/../libs/nats-2.14.x-2.16.5-scenario.jar &
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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>nats-2.14.x-2.15.x-scenario</artifactId>
<artifactId>nats-2.14.x-2.16.5-scenario</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

Expand Down Expand Up @@ -75,7 +75,7 @@
</dependencies>

<build>
<finalName>nats-2.14.x-2.15.x-scenario</finalName>
<finalName>nats-2.14.x-2.16.5-scenario</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -112,4 +112,4 @@

</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<files>
<file>
<source>${project.build.directory}/nats-2.14.x-2.15.x-scenario.jar</source>
<source>${project.build.directory}/nats-2.14.x-2.16.5-scenario.jar</source>
<outputDirectory>./libs</outputDirectory>
<fileMode>0775</fileMode>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

2.16.5
2.15.6
2.14.2
2.14.2

0 comments on commit 24ec663

Please sign in to comment.