Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
be675c2
Feat: Add a plugin that supports the Solon framework.
xsShuang Jun 20, 2024
06732e8
Update ComponentsDefine.java
xsShuang Jun 20, 2024
924c61f
Add Solon plugin test
xsShuang Jun 20, 2024
ffd56db
Merge remote-tracking branch 'origin/main'
xsShuang Jun 20, 2024
dbd24b4
Add Solon plugin test
xsShuang Jun 20, 2024
0b2afff
Add Solon plugin test and update doc.
xsShuang Jun 22, 2024
b96e8c5
Merge remote-tracking branch 'origin/main'
xsShuang Jun 22, 2024
88ef3ca
merge the latest commits.
xsShuang Jun 22, 2024
0716d24
Modify the test code.
xsShuang Jun 22, 2024
1704f4d
Modify the test code.
xsShuang Jun 22, 2024
0d32357
Improvement of processing span code and test case information
xsShuang Jun 22, 2024
47eb826
Modify the test code.
xsShuang Jun 22, 2024
c77ba51
Merge branch 'apache:main' into main
xsShuang Jun 26, 2024
4b772bf
Merge remote-tracking branch 'origin/main'
xsShuang Jun 26, 2024
b68aa80
Modify the test code.
xsShuang Jun 26, 2024
62884f5
Merge remote-tracking branch 'origin/main'
xsShuang Jun 26, 2024
c05c8f8
update skywalking-solon-2.x-scenario pom.xml
xsShuang Jun 26, 2024
05bc9e5
Modify the test code.
xsShuang Jun 27, 2024
ae6c7cf
Merge pull request #1 from xsShuang/dev
xsShuang Jun 27, 2024
d253974
modify def file
xsShuang Jun 27, 2024
20a3507
Merge pull request #2 from xsShuang/dev
xsShuang Jun 27, 2024
2b72e14
update solon plugin
xsShuang Jun 27, 2024
8fcb404
Modify the test code.
xsShuang Jun 27, 2024
a8cb8c3
Modify the test code.
xsShuang Jun 27, 2024
f6ffd0e
Merge pull request #3 from xsShuang/dev
xsShuang Jun 27, 2024
3ace531
Add plugin configuration and instructions
xsShuang Jun 28, 2024
53b9c5a
Add plugin configuration and instructions
xsShuang Jun 28, 2024
ca6ff8b
Modify the test code.
xsShuang Jun 28, 2024
c205c1a
Merge pull request #4 from xsShuang/dev
xsShuang Jun 28, 2024
4b5e558
Add plugin configuration and instructions
xsShuang Jun 28, 2024
5fbdc2a
Merge pull request #5 from xsShuang/dev
xsShuang Jun 28, 2024
4982488
Add plugin configuration and instructions
xsShuang Jun 28, 2024
916dc21
Merge pull request #6 from xsShuang/dev
xsShuang Jun 28, 2024
505e99c
Modified to V2 version of the interceptor
xsShuang Jun 28, 2024
115727f
Modified to V2 version of the interceptor
xsShuang Jun 28, 2024
24799a6
Modified to V2 version of the interceptor
xsShuang Jun 28, 2024
22a4a8f
Merge pull request #7 from xsShuang/dev
xsShuang Jun 28, 2024
3524717
Modified to V2 version of the interceptor
xsShuang Jun 28, 2024
160668c
Remove the code that collects all headers by default
xsShuang Jun 28, 2024
08bdfcb
Merge pull request #8 from xsShuang/dev
xsShuang Jun 28, 2024
38cb7b1
Optimised code
xsShuang Jun 28, 2024
193b532
Modify the test code.
xsShuang Jun 28, 2024
20c3545
Modify the test code.
xsShuang Jun 28, 2024
9f3392e
Merge pull request #9 from xsShuang/dev
xsShuang Jun 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/plugins-test.3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ jobs:
- grpc-generic-call-scenario
- shenyu-2.4.x-grpc-scenario
- shenyu-2.4.x-sofarpc-scenario
- solon-2.x-scenario
steps:
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Release Notes.
* Fixed the invalid issue in the isInterface method in PluginFinder.
* Fix the opentracing toolkit SPI config
* Improve 4x performance of ContextManagerExtendService.createTraceContext()
* Add a plugin that supports the Solon framework.


All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/213?closed=1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,6 @@ public class ComponentsDefine {

public static final OfficialComponent OCEANBASE_JDBC_DRIVER = new OfficialComponent(157, "OceanBase-jdbc-driver");

public static final OfficialComponent SOLON_MVC = new OfficialComponent(158, "SolonMVC");

}
1 change: 1 addition & 0 deletions apm-sniffer/apm-sdk-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
<module>rocketMQ-client-java-5.x-plugin</module>
<module>activemq-artemis-jakarta-client-2.x-plugin</module>
<module>c3p0-0.9.x-plugin</module>
<module>solon-2.x-plugin</module>
</modules>
<packaging>pom</packaging>

Expand Down
48 changes: 48 additions & 0 deletions apm-sniffer/apm-sdk-plugin/solon-2.x-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0"?>
<!--
~ 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>
<artifactId>apm-sdk-plugin</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>9.3.0-SNAPSHOT</version>
</parent>

<artifactId>solon-2.x-plugin</artifactId>
<packaging>jar</packaging>

<name>solon-2.x-plugin</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<apache-httpclient.version>4.3</apache-httpclient.version>
<junit.version>4.12</junit.version>
</properties>

<dependencies>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-lib</artifactId>
<version>2.8.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* 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.solon;

import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
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.context.trace.SpanLayer;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.v2.InstanceMethodsAroundInterceptorV2;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.v2.MethodInvocationContext;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.apache.skywalking.apm.util.StringUtil;
import org.noear.solon.core.NvMap;
import org.noear.solon.core.handle.Context;

import java.lang.reflect.Method;

@Slf4j
public class SolonActionExecuteInterceptor implements InstanceMethodsAroundInterceptorV2 {

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInvocationContext context) throws Throwable {
Context ctx = (Context) allArguments[0];
ContextCarrier contextCarrier = new ContextCarrier();
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
next.setHeadValue(ctx.header(next.getHeadKey()));
}
String operationName = ctx.method() + ":" + ctx.path();
AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier);
span.setComponent(ComponentsDefine.SOLON_MVC);
SpanLayer.asHttp(span);
Tags.URL.set(span, ctx.url());
Tags.HTTP.METHOD.set(span, ctx.method());
if (SolonPluginConfig.Plugin.Solon.INCLUDE_HTTP_HEADERS != null && !SolonPluginConfig.Plugin.Solon.INCLUDE_HTTP_HEADERS.isEmpty()) {
NvMap includeHeaders = new NvMap();
for (String header : SolonPluginConfig.Plugin.Solon.INCLUDE_HTTP_HEADERS) {
String value = ctx.header(header);
if (StringUtil.isNotBlank(value)) {
includeHeaders.put(header, value);
}
}
Tags.HTTP.HEADERS.set(span, includeHeaders.toString());
}
if (SolonPluginConfig.Plugin.Solon.HTTP_BODY_LENGTH_THRESHOLD != 0) {
String body = ctx.body();
if (StringUtil.isNotBlank(body)) {
if (SolonPluginConfig.Plugin.Solon.HTTP_BODY_LENGTH_THRESHOLD > 0 && body.length() > SolonPluginConfig.Plugin.Solon.HTTP_BODY_LENGTH_THRESHOLD) {
body = body.substring(0, SolonPluginConfig.Plugin.Solon.HTTP_BODY_LENGTH_THRESHOLD);
}
Tags.HTTP.BODY.set(span, body);
}
}
if (SolonPluginConfig.Plugin.Solon.HTTP_PARAMS_LENGTH_THRESHOLD != 0) {
String param = ctx.paramMap().toString();
if (SolonPluginConfig.Plugin.Solon.HTTP_PARAMS_LENGTH_THRESHOLD > 0 && param.length() > SolonPluginConfig.Plugin.Solon.HTTP_PARAMS_LENGTH_THRESHOLD) {
param = param.substring(0, SolonPluginConfig.Plugin.Solon.HTTP_PARAMS_LENGTH_THRESHOLD);
}
Tags.HTTP.PARAMS.set(span, param);
}
}

@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret, MethodInvocationContext context) {
Context ctx = (Context) allArguments[0];
Tags.HTTP_RESPONSE_STATUS_CODE.set(ContextManager.activeSpan(), ctx.status());
if (ctx.errors != null && context.getContext() == null) {
AbstractSpan activeSpan = ContextManager.activeSpan();
activeSpan.errorOccurred();
activeSpan.log(ctx.errors);
}
ContextManager.stopSpan();
return ret;
}

@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t, MethodInvocationContext context) {
AbstractSpan activeSpan = ContextManager.activeSpan();
activeSpan.errorOccurred();
activeSpan.log(t);
context.setContext(true);
}
}
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.solon;

import org.apache.skywalking.apm.agent.core.boot.PluginConfig;

import java.util.List;

public class SolonPluginConfig {
public static class Plugin {
@PluginConfig(root = SolonPluginConfig.class)
public static class Solon {
/**
* Define the max length of collected HTTP parameters. The default value(=0) means not collecting.
*/
public static int HTTP_PARAMS_LENGTH_THRESHOLD = 0;
/**
* Define the max length of collected HTTP body. The default value(=0) means not collecting.
*/
public static int HTTP_BODY_LENGTH_THRESHOLD = 0;
/**
* It controls what header data should be collected, values must be in lower case, if empty, no header data will be collected. default is empty.
*/
public static List<String> INCLUDE_HTTP_HEADERS ;
}
}
}
Original file line number Diff line number Diff line change
@@ -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.solon.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.enhance.v2.ClassInstanceMethodsEnhancePluginDefineV2;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.v2.InstanceMethodsInterceptV2Point;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;

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

public class SolonActionInstrumentation extends ClassInstanceMethodsEnhancePluginDefineV2 {

private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.solon.SolonActionExecuteInterceptor";

@Override
public ClassMatch enhanceClass() {
return NameMatch.byName("org.noear.solon.SolonApp");
}

@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
}

@Override
public InstanceMethodsInterceptV2Point[] getInstanceMethodsInterceptV2Points() {
return new InstanceMethodsInterceptV2Point[] {
new InstanceMethodsInterceptV2Point() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("tryHandle");
}

@Override
public String getMethodsInterceptorV2() {
return INTERCEPT_CLASS;
}

@Override
public boolean isOverrideArgs() {
return true;
}
}
};
}
}
Original file line number Diff line number Diff line change
@@ -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.

solon-2.x=org.apache.skywalking.apm.plugin.solon.define.SolonActionInstrumentation
6 changes: 6 additions & 0 deletions apm-sniffer/config/agent.config
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,9 @@ plugin.nettyhttp.supported_content_types_prefix=${SW_PLUGIN_NETTYHTTP_SUPPORTED_
plugin.rocketmqclient.collect_message_keys=${SW_PLUGIN_ROCKETMQCLIENT_COLLECT_MESSAGE_KEYS:false}
# If set to true, the tags of messages would be collected by the plugin for RocketMQ Java client.
plugin.rocketmqclient.collect_message_tags=${SW_PLUGIN_ROCKETMQCLIENT_COLLECT_MESSAGE_TAGS:false}
# Define the max length of collected HTTP parameters. The default value(=0) means not collecting.
plugin.solon.http_params_length_threshold=${SW_PLUGIN_SOLON_HTTP_PARAMS_LENGTH_THRESHOLD:0}
# It controls what header data should be collected, values must be in lower case, if empty, no header data will be collected. default is empty.
plugin.solon.include_http_headers=${SW_PLUGIN_SOLON_INCLUDE_HTTP_HEADERS:}
# Define the max length of collected HTTP body. The default value(=0) means not collecting.
plugin.solon.http_body_length_threshold=${SW_PLUGIN_SOLON_HTTP_BODY_LENGTH_THRESHOLD:0}
1 change: 1 addition & 0 deletions docs/en/setup/service-agent/java-agent/Plugin-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,4 @@
- spring-webflux-6.x-webclient
- activemq-artemis-jakarta-client-2.x
- c3p0-0.9.x
- solon-2.x
1 change: 1 addition & 0 deletions docs/en/setup/service-agent/java-agent/Supported-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ metrics based on the tracing data.
* [Grizzly](https://github.com/eclipse-ee4j/grizzly) 2.3.x -> 4.x
* [WebSphere Liberty](https://github.com/OpenLiberty/open-liberty) 23.x
* [Netty HTTP](https://github.com/netty/netty) 4.1.x (Optional²)
* [Solon](https://github.com/opensolon/solon) 2.7.x -> 2.8.x
* HTTP Client
* [Feign](https://github.com/OpenFeign/feign) 9.x
* [Netflix Spring Cloud Feign](https://github.com/spring-cloud/spring-cloud-openfeign) 1.1.x -> 2.x
Expand Down
Loading