-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Support RESTEasy 3.x #2665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Support RESTEasy 3.x #2665
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0e43088
feat(agent sdk): resteasy plugin
yanfch a89db6e
Merge branch 'master' into feature/RESTEasy-plugin
yanfch a20bc0c
fix(agent sdk): fix component define
yanfch adef2cb
fix(agent sdk): fix file license
yanfch 89b805f
fix(agent sdk): fix file license
yanfch 2b38dc0
docs(agent sdk): add supported list
yanfch 2803cd9
fix(agent sdk): fix file license
yanfch 13ce4d5
fix(agent sdk): fix response error tag
yanfch 4f0494c
Merge remote-tracking branch 'origin/master' into feature/RESTEasy-pl…
yanfch 043a21d
fix(agent sdk): fix
yanfch a854bd3
Merge branch 'master' into feature/RESTEasy-plugin
yanfch e9cfbb0
Merge branch 'master' of https://github.com/apache/skywalking into fe…
yanfch 7b0c96d
fix(agent sdk): adapter 3.5+
yanfch a623544
Merge remote-tracking branch 'upstream/master' into feature/RESTEasy-…
yanfch 200c27d
fix(agent sdk): remove unreasonable async handling
yanfch 9b05c6a
Merge branch 'master' into feature/RESTEasy-plugin
wu-sheng ac5eed7
Merge branch 'master' into feature/RESTEasy-plugin
wu-sheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <?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>apm-sdk-plugin</artifactId> | ||
| <version>6.2.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>resteasy-plugin</artifactId> | ||
| <modules> | ||
| <module>resteasy-server-3.x-plugin</module> | ||
| </modules> | ||
|
|
||
| <packaging>pom</packaging> | ||
|
|
||
| <name>resteasy-plugin</name> | ||
| <url>http://maven.apache.org</url> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <sdk.plugin.related.dir>/..</sdk.plugin.related.dir> | ||
| </properties> | ||
| </project> |
47 changes: 47 additions & 0 deletions
47
apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-3.x-plugin/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?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> | ||
| <artifactId>resteasy-plugin</artifactId> | ||
| <groupId>org.apache.skywalking</groupId> | ||
| <version>6.2.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>resteasy-server-3.x-plugin</artifactId> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <name>apm-resteasy-server-3.x-plugin</name> | ||
| <url>http://maven.apache.org</url> | ||
|
|
||
| <properties> | ||
| <resteasy.version>3.1.0.Final</resteasy.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.jboss.resteasy</groupId> | ||
| <artifactId>resteasy-jaxrs</artifactId> | ||
| <version>${resteasy.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
53 changes: 53 additions & 0 deletions
53
...e/skywalking/apm/plugin/resteasy/v3/server/SynchronousDispatcherExceptionInterceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * 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.resteasy.v3.server; | ||
|
|
||
| import org.apache.skywalking.apm.agent.core.context.ContextManager; | ||
| 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.jboss.resteasy.spi.HttpRequest; | ||
|
|
||
| import java.lang.reflect.Method; | ||
|
|
||
| /** | ||
| * @author yan-fucheng | ||
| */ | ||
| public class SynchronousDispatcherExceptionInterceptor implements InstanceMethodsAroundInterceptor { | ||
|
|
||
| @Override | ||
| public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, | ||
| MethodInterceptResult result) throws Throwable { | ||
| if (ContextManager.isActive() && !((HttpRequest) allArguments[0]).getAsyncContext().isSuspended()) { | ||
| ContextManager.activeSpan().errorOccurred().log((Throwable)allArguments[2]); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, | ||
| Object ret) throws Throwable { | ||
| return ret; | ||
| } | ||
|
|
||
| @Override | ||
| public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
| Class<?>[] argumentsTypes, Throwable t) { | ||
| ContextManager.activeSpan().errorOccurred().log(t); | ||
| } | ||
| } |
86 changes: 86 additions & 0 deletions
86
...org/apache/skywalking/apm/plugin/resteasy/v3/server/SynchronousDispatcherInterceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * 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.resteasy.v3.server; | ||
|
|
||
| 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.InstanceMethodsAroundInterceptor; | ||
| import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; | ||
| import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; | ||
| import org.jboss.resteasy.spi.HttpRequest; | ||
| import org.jboss.resteasy.spi.HttpResponse; | ||
|
|
||
| import java.lang.reflect.Method; | ||
|
|
||
| /** | ||
| * @author yan-fucheng | ||
| */ | ||
| public class SynchronousDispatcherInterceptor implements InstanceMethodsAroundInterceptor { | ||
|
|
||
| @Override | ||
| public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, | ||
| MethodInterceptResult result) throws Throwable { | ||
| HttpRequest request = (HttpRequest) allArguments[0]; | ||
|
|
||
| ContextCarrier contextCarrier = new ContextCarrier(); | ||
| CarrierItem next = contextCarrier.items(); | ||
| while (next.hasNext()) { | ||
| next = next.next(); | ||
| next.setHeadValue(request.getHttpHeaders().getHeaderString(next.getHeadKey())); | ||
| } | ||
|
|
||
| AbstractSpan span = ContextManager.createEntrySpan(request.getUri().getPath(), contextCarrier); | ||
| Tags.URL.set(span, toPath(request.getUri().getRequestUri().toString())); | ||
| Tags.HTTP.METHOD.set(span, request.getHttpMethod()); | ||
| span.setComponent(ComponentsDefine.RESTEASY); | ||
| SpanLayer.asHttp(span); | ||
| } | ||
|
|
||
| @Override | ||
| public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, | ||
| Object ret) throws Throwable { | ||
| HttpResponse response = (HttpResponse) allArguments[1]; | ||
| AbstractSpan span = ContextManager.activeSpan(); | ||
| if (response.getStatus() >= 400) { | ||
| span.errorOccurred(); | ||
| Tags.STATUS_CODE.set(span, Integer.toString(response.getStatus())); | ||
| } | ||
| ContextManager.stopSpan(); | ||
| return ret; | ||
| } | ||
|
|
||
| @Override | ||
| public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
| Class<?>[] argumentsTypes, Throwable t) { | ||
| ContextManager.activeSpan().errorOccurred().log(t); | ||
|
yanfch marked this conversation as resolved.
|
||
| } | ||
|
|
||
| private static String toPath(String uri) { | ||
| if (uri.contains("?")) { | ||
| return uri.substring(0, uri.indexOf("?")); | ||
| } else { | ||
| return uri; | ||
| } | ||
| } | ||
| } | ||
89 changes: 89 additions & 0 deletions
89
...skywalking/apm/plugin/resteasy/v3/server/define/SynchronousDispatcherInstrumentation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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.resteasy.v3.server.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 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; | ||
| import static net.bytebuddy.matcher.ElementMatchers.takesArguments; | ||
|
|
||
| /** | ||
| * @author yan-fucheng | ||
| */ | ||
| public class SynchronousDispatcherInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { | ||
|
|
||
| private static final String ENHANCE_CLASS = "org.jboss.resteasy.core.SynchronousDispatcher"; | ||
|
|
||
| private static final String INVOKE_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.resteasy.v3.server.SynchronousDispatcherInterceptor"; | ||
| private static final String INVOKE_EXCEPTION_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.resteasy.v3.server.SynchronousDispatcherExceptionInterceptor"; | ||
|
|
||
| @Override | ||
| protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { | ||
| return new InstanceMethodsInterceptPoint[] { | ||
| new InstanceMethodsInterceptPoint() { | ||
| @Override | ||
| public ElementMatcher<MethodDescription> getMethodsMatcher() { | ||
| return named("invoke").and(takesArguments(3)); | ||
| } | ||
|
|
||
| @Override | ||
| public String getMethodsInterceptor() { | ||
| return INVOKE_INTERCEPT_CLASS; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isOverrideArgs() { | ||
| return false; | ||
| } | ||
| }, | ||
| new InstanceMethodsInterceptPoint() { | ||
| @Override | ||
| public ElementMatcher<MethodDescription> getMethodsMatcher() { | ||
| return named("writeException").and(takesArguments(3)); | ||
| } | ||
|
|
||
| @Override | ||
| public String getMethodsInterceptor() { | ||
| return INVOKE_EXCEPTION_INTERCEPT_CLASS; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isOverrideArgs() { | ||
| return false; | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| @Override | ||
| protected ClassMatch enhanceClass() { | ||
| return NameMatch.byName(ENHANCE_CLASS); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
...lugin/resteasy-plugin/resteasy-server-3.x-plugin/src/main/resources/skywalking-plugin.def
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
|
|
||
| resteasy-server-3.x=org.apache.skywalking.apm.plugin.resteasy.v3.server.define.SynchronousDispatcherInstrumentation |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.