Skip to content

Commit e464f18

Browse files
authored
Add WebSphere Liberty 23.x plugin.(#10887) (#560)
1 parent b9dd0f2 commit e464f18

38 files changed

Lines changed: 1922 additions & 1 deletion

File tree

.github/workflows/plugins-test.2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
- rocketmq-scenario
8080
- jersey-2.0.x-2.25.x-scenario
8181
- jersey-2.26.x-2.39.x-scenario
82+
- websphere-liberty-23.x-scenario
8283
steps:
8384
- uses: actions/checkout@v2
8485
with:

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Callable {
137137
* Fix the conflict between the logging kernel and the JDK threadpool plugin.
138138
* Fix the thread safety bug of finishing operation for the span named "SpringCloudGateway/sendRequest"
139139
* Fix NPE in guava-eventbus-plugin.
140+
* Add WebSphere Liberty 23.x plugin
140141

141142
#### Documentation
142143

apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,5 @@ public class ComponentsDefine {
237237

238238
public static final OfficialComponent GRIZZLY = new OfficialComponent(147, "Grizzly");
239239

240+
public static final OfficialComponent WEBSPHERE = new OfficialComponent(148, "WebSphere");
240241
}

apm-sniffer/apm-sdk-plugin/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
<module>grizzly-2.3.x-4.x-plugin</module>
133133
<module>grizzly-2.3.x-4.x-work-threadpool-plugin</module>
134134
<module>rocketMQ-5.x-plugin</module>
135+
<module>websphere-liberty-23.x-plugin</module>
135136
</modules>
136137
<packaging>pom</packaging>
137138

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
~
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<parent>
24+
<artifactId>apm-sdk-plugin</artifactId>
25+
<groupId>org.apache.skywalking</groupId>
26+
<version>9.0.0-SNAPSHOT</version>
27+
</parent>
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<artifactId>websphere-liberty-23.x-plugin</artifactId>
31+
32+
<properties>
33+
<junit.version>4.12</junit.version>
34+
</properties>
35+
36+
<dependencies>
37+
<dependency>
38+
<groupId>junit</groupId>
39+
<artifactId>junit</artifactId>
40+
<version>${junit.version}</version>
41+
<scope>test</scope>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-jar-plugin</artifactId>
50+
<configuration>
51+
<excludes>
52+
<exclude>com/ibm/websphere/servlet/request/**</exclude>
53+
<exclude>com/ibm/ws/webcontainer/async/**</exclude>
54+
</excludes>
55+
</configuration>
56+
</plugin>
57+
</plugins>
58+
</build>
59+
</project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package com.ibm.websphere.servlet.request;
20+
21+
/**
22+
* mock class for compile, will be removed from final package jar
23+
*/
24+
public interface IRequest {
25+
26+
String getMethod();
27+
28+
String getScheme();
29+
30+
String getHeader(String name);
31+
32+
String getRequestURI();
33+
34+
int getServerPort();
35+
36+
String getServerName();
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package com.ibm.ws.webcontainer.async;
20+
21+
/**
22+
* mock class for compile, will be removed from final package jar
23+
*/
24+
public class CompleteRunnable implements Runnable {
25+
@Override
26+
public void run() {
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package com.ibm.ws.webcontainer.async;
20+
21+
/**
22+
* mock class for compile, will be removed from final package jar
23+
*/
24+
public class DispatchRunnable implements Runnable {
25+
@Override
26+
public void run() {
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.websphereliberty.v23;
20+
21+
import java.lang.reflect.Method;
22+
import org.apache.skywalking.apm.agent.core.context.ContextManager;
23+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
24+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
25+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
26+
import org.apache.skywalking.apm.plugin.websphereliberty.v23.async.AsyncType;
27+
28+
public class AsyncContextInterceptor implements InstanceMethodsAroundInterceptor {
29+
30+
@Override
31+
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
32+
MethodInterceptResult result) throws Throwable {
33+
Runnable runnable = (Runnable) allArguments[0];
34+
allArguments[0] = AsyncType.doWrap(runnable);
35+
}
36+
37+
@Override
38+
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
39+
Object ret) throws Throwable {
40+
return ret;
41+
}
42+
43+
@Override
44+
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
45+
Class<?>[] argumentsTypes, Throwable t) {
46+
ContextManager.activeSpan().log(t);
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.websphereliberty.v23;
20+
21+
import com.ibm.websphere.servlet.request.IRequest;
22+
import java.lang.reflect.Method;
23+
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
24+
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
25+
import org.apache.skywalking.apm.agent.core.context.ContextManager;
26+
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
27+
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
28+
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
29+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
30+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
31+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
32+
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
33+
34+
public class DynamicVirtualHostInterceptor implements InstanceMethodsAroundInterceptor {
35+
36+
@Override
37+
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
38+
MethodInterceptResult result) throws Throwable {
39+
40+
}
41+
42+
@Override
43+
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
44+
Object ret) throws Throwable {
45+
if (ret == null) {
46+
IRequest request = (IRequest) allArguments[0];
47+
ContextCarrier contextCarrier = new ContextCarrier();
48+
49+
CarrierItem next = contextCarrier.items();
50+
while (next.hasNext()) {
51+
next = next.next();
52+
next.setHeadValue(request.getHeader(next.getHeadKey()));
53+
}
54+
55+
String operationName = String.join(":", request.getMethod(), request.getRequestURI());
56+
AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier);
57+
58+
String url = request.getScheme() + "://" +
59+
request.getServerName() + ":" + request.getServerPort() + request.getRequestURI();
60+
Tags.URL.set(span, url);
61+
Tags.HTTP.METHOD.set(span, request.getMethod());
62+
63+
span.setComponent(ComponentsDefine.WEBSPHERE);
64+
SpanLayer.asHttp(span);
65+
66+
Tags.HTTP_RESPONSE_STATUS_CODE.set(span, 404);
67+
68+
span.errorOccurred();
69+
70+
ContextManager.stopSpan();
71+
}
72+
return ret;
73+
}
74+
75+
@Override
76+
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
77+
Class<?>[] argumentsTypes, Throwable t) {
78+
}
79+
}

0 commit comments

Comments
 (0)