-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Support Quasar fiber tracing #4951
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7693ba5
add Quasar plugin
zhaoyuguang d2a0309
Merge branch 'master' into zyg/quasar
zhaoyuguang fb6c2be
add test
zhaoyuguang 8a3f720
Merge branch 'zyg/quasar' of https://github.com/zhaoyuguang/incubator…
zhaoyuguang 26dcbc5
Merge branch 'master' into zyg/quasar
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
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,45 @@ | ||
| <?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> | ||
| <groupId>org.apache.skywalking</groupId> | ||
| <artifactId>apm-sdk-plugin</artifactId> | ||
| <version>8.1.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>apm-quasar-plugin</artifactId> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <name>quasar-plugin</name> | ||
| <url>http://maven.apache.org</url> | ||
| <properties> | ||
| <quasar-core.version>0.7.10</quasar-core.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>co.paralleluniverse</groupId> | ||
| <artifactId>quasar-core</artifactId> | ||
| <version>${quasar-core.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
68 changes: 68 additions & 0 deletions
68
...quasar-plugin/src/main/java/org/apache/skywalking/apm/plugin/quasar/FiberInterceptor.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,68 @@ | ||
| /* | ||
| * 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.quasar; | ||
|
|
||
| import org.apache.skywalking.apm.agent.core.context.ContextManager; | ||
| import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; | ||
| import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; | ||
| import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; | ||
| import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor; | ||
| 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 java.lang.reflect.Method; | ||
|
|
||
| public class FiberInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor { | ||
|
|
||
| private static final String OPERATION_NAME = "QUASAR/Fiber"; | ||
|
|
||
| @Override | ||
| public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, | ||
| MethodInterceptResult result) throws Throwable { | ||
| AbstractSpan span = ContextManager.createLocalSpan(OPERATION_NAME); | ||
| span.setComponent(ComponentsDefine.QUASAR); | ||
| if (objInst.getSkyWalkingDynamicField() != null) { | ||
| ContextManager.continued((ContextSnapshot) objInst.getSkyWalkingDynamicField()); | ||
| objInst.setSkyWalkingDynamicField(null); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, | ||
| Object ret) throws Throwable { | ||
| ContextManager.stopSpan(); | ||
| return ret; | ||
| } | ||
|
|
||
| @Override | ||
| public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
| Class<?>[] argumentsTypes, Throwable t) { | ||
| AbstractSpan span = ContextManager.activeSpan(); | ||
| span.errorOccurred(); | ||
| span.log(t); | ||
| } | ||
|
|
||
| @Override | ||
| public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { | ||
| if (ContextManager.isActive()) { | ||
| objInst.setSkyWalkingDynamicField(ContextManager.capture()); | ||
| } | ||
| } | ||
| } |
82 changes: 82 additions & 0 deletions
82
...in/src/main/java/org/apache/skywalking/apm/plugin/quasar/define/FiberInstrumentation.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,82 @@ | ||
| /* | ||
| * 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.quasar.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 static net.bytebuddy.matcher.ElementMatchers.isProtected; | ||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||
| import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; | ||
| import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; | ||
|
|
||
| public class FiberInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { | ||
|
|
||
| private static final String ENHANCE_CLASS = "co.paralleluniverse.fibers.Fiber"; | ||
|
|
||
| private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.quasar.FiberInterceptor"; | ||
|
|
||
| @Override | ||
| public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { | ||
| return new ConstructorInterceptPoint[] { | ||
| new ConstructorInterceptPoint() { | ||
| @Override | ||
| public ElementMatcher<MethodDescription> getConstructorMatcher() { | ||
| return takesArgumentWithType(3, "co.paralleluniverse.strands.SuspendableCallable"); | ||
| } | ||
|
|
||
| @Override | ||
| public String getConstructorInterceptor() { | ||
| return INTERCEPTOR_CLASS; | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| @Override | ||
| public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { | ||
| return new InstanceMethodsInterceptPoint[] { | ||
| new InstanceMethodsInterceptPoint() { | ||
| @Override | ||
| public ElementMatcher<MethodDescription> getMethodsMatcher() { | ||
| return isProtected().and(named("run")); | ||
| } | ||
|
|
||
| @Override | ||
| public String getMethodsInterceptor() { | ||
| return INTERCEPTOR_CLASS; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isOverrideArgs() { | ||
| return false; | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| @Override | ||
| public ClassMatch enhanceClass() { | ||
| return byName(ENHANCE_CLASS); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
apm-sniffer/apm-sdk-plugin/quasar-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. | ||
|
|
||
| quasar=org.apache.skywalking.apm.plugin.quasar.define.FiberInstrumentation |
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
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,21 @@ | ||
| #!/bin/bash | ||
| # | ||
| # 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. | ||
|
|
||
| home="$(cd "$(dirname $0)"; pwd)" | ||
|
|
||
| java -jar ${agent_opts} -Dco.paralleluniverse.fibers.detectRunawayFibers=false ${home}/../libs/quasar-scenario.jar & |
70 changes: 70 additions & 0 deletions
70
test/plugin/scenarios/quasar-scenario/config/expectedData.yaml
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,70 @@ | ||
| # 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. | ||
| segmentItems: | ||
| - serviceName: quasar-scenario | ||
| segmentSize: ge 3 | ||
| segments: | ||
| - segmentId: not null | ||
| spans: | ||
| - operationName: /quasar-scenario/case/quasar-scenario | ||
| operationId: 0 | ||
| parentSpanId: -1 | ||
| spanId: 0 | ||
| spanLayer: Http | ||
| startTime: nq 0 | ||
| endTime: nq 0 | ||
| componentId: 1 | ||
| isError: false | ||
| spanType: Entry | ||
| peer: '' | ||
| skipAnalysis: false | ||
| tags: | ||
| - {key: url, value: 'http://localhost:8080/quasar-scenario/case/quasar-scenario'} | ||
| - {key: http.method, value: GET} | ||
| - segmentId: not null | ||
| spans: | ||
| - operationName: /quasar-scenario/case/ping | ||
| operationId: 0 | ||
| parentSpanId: 0 | ||
| spanId: 1 | ||
| spanLayer: Http | ||
| startTime: nq 0 | ||
| endTime: nq 0 | ||
| componentId: 12 | ||
| isError: false | ||
| spanType: Exit | ||
| peer: localhost:8080 | ||
| skipAnalysis: false | ||
| tags: | ||
| - {key: http.method, value: GET} | ||
| - {key: url, value: 'http://localhost:8080/quasar-scenario/case/ping'} | ||
| - operationName: QUASAR/Fiber | ||
| operationId: 0 | ||
| parentSpanId: -1 | ||
| spanId: 0 | ||
| spanLayer: Unknown | ||
| startTime: nq 0 | ||
| endTime: nq 0 | ||
| componentId: 88 | ||
| isError: false | ||
| spanType: Local | ||
| peer: '' | ||
| skipAnalysis: false | ||
| refs: | ||
| - {parentEndpoint: /quasar-scenario/case/quasar-scenario, networkAddress: '', | ||
| refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, | ||
| parentServiceInstance: not null, parentService: quasar-scenario, | ||
| traceId: not null} | ||
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,20 @@ | ||
| # 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. | ||
|
|
||
| type: jvm | ||
| entryService: http://localhost:8080/quasar-scenario/case/quasar-scenario | ||
| healthCheck: http://localhost:8080/quasar-scenario/case/healthCheck | ||
| startScript: ./bin/startup.sh |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guasar Fiber is not an async bridge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, main thread is Http entry, async is Fiber and http exit