You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "lsq27 (via GitHub)" <gi...@apache.org> on 2023/08/15 16:11:28 UTC
[GitHub] [skywalking-java] lsq27 opened a new pull request, #594: Add Spring runner plugin
lsq27 opened a new pull request, #594:
URL: https://github.com/apache/skywalking-java/pull/594
<!--
⚠️ Please make sure to read this template first, pull requests that don't accord with this template
maybe closed without notice.
Texts surrounded by `<` and `>` are meant to be replaced by you, e.g. <framework name>, <issue number>.
Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]`
-->
<!-- ==== 🐛 Remove this line WHEN AND ONLY WHEN you're fixing a bug, follow the checklist 👇 ====
### Fix <bug description or the bug issue number or bug issue link>
- [ ] Add a unit test to verify that the fix works.
- [ ] Explain briefly why the bug exists and how to fix it.
==== 🐛 Remove this line WHEN AND ONLY WHEN you're fixing a bug, follow the checklist 👆 ==== -->
### Add an agent plugin to support [Spring runner](https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.spring-application.command-line-runner)
- [x] Add a test case for the new plugin, refer to [the doc](https://github.com/apache/skywalking-java/blob/main/docs/en/setup/service-agent/java-agent/Plugin-test.md)
- [x] Add a component id in [the component-libraries.yml](https://github.com/apache/skywalking/blob/master/oap-server/server-starter/src/main/resources/component-libraries.yml)
- [ ] Add a logo in [the UI repo](https://github.com/apache/skywalking-rocketbot-ui/tree/master/src/views/components/topology/assets)
<!-- ==== 📈 Remove this line WHEN AND ONLY WHEN you're improving the performance, follow the checklist 👇 ====
### Improve the performance of <class or module or ...>
- [ ] Add a benchmark for the improvement, refer to [the existing ones](https://github.com/apache/skywalking-java/blob/main/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/LinkedArrayBenchmark.java)
- [ ] The benchmark result.
```text
<Paste the benchmark results here>
```
- [ ] Links/URLs to the theory proof or discussion articles/blogs. <links/URLs here>
==== 📈 Remove this line WHEN AND ONLY WHEN you're improving the performance, follow the checklist 👆 ==== -->
<!-- ==== 🆕 Remove this line WHEN AND ONLY WHEN you're adding a new feature, follow the checklist 👇 ====
### <Feature description>
- [ ] If this is non-trivial feature, paste the links/URLs to the design doc.
- [ ] Update the documentation to include this new feature.
- [ ] Tests(including UT, IT, E2E) are added to verify the new feature.
- [ ] If it's UI related, attach the screenshots below.
==== 🆕 Remove this line WHEN AND ONLY WHEN you're adding a new feature, follow the checklist 👆 ==== -->
- [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #<issue number>.
- [x] Update the [`CHANGES` log](https://github.com/apache/skywalking-java/blob/main/CHANGES.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] lsq27 commented on pull request #594: Add Spring Runner plugin
Posted by "lsq27 (via GitHub)" <gi...@apache.org>.
lsq27 commented on PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#issuecomment-1682358318
> If this is a one time running, especially on booting stage, I am highly doubt whether agent always monitors this. The agent would not work until it is connected with backend, but the runner could have finished by then.
>
> SkyWalking is monitoring server style application running status, rather than booting details.
Spring runners only run when Spring has fully started, just like a user is accessing a normal endpoint and then some code in controller run.
So it is possible that a application is ready to accept user traffic but the agent can not trace the user access until it is connected with backend? If so, this plugin may not work sometimes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #594: Add Spring Runner plugin
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#discussion_r1295287681
##########
apm-sniffer/apm-sdk-plugin/spring-plugins/runner-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/runner/RunnerMethodInterceptor.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.spring.runner;
+
+import java.lang.reflect.Method;
+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.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;
+
+/**
+ * Record the Spring runner task local span.
+ */
+public class RunnerMethodInterceptor implements InstanceMethodsAroundInterceptor {
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ String operationName = ComponentsDefine.SPRING_RUNNER.getName() + "/" + allArguments[0].getClass().getName();
+ AbstractSpan span = ContextManager.createLocalSpan(operationName);
+ Tags.LOGIC_ENDPOINT.set(span, Tags.VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT);
Review Comment:
Create a logic span in plugin? Why do we need to measure a local run?
I have doubts about whether this is a general use case. If you want to measure this, the toolkit annotation and APIs could help you, rather than a public plugin.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on pull request #594: Add Spring Runner plugin
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#issuecomment-1681988205
@lsq27 Any feedback about the use case concern.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] lsq27 commented on pull request #594: Add Spring Runner plugin
Posted by "lsq27 (via GitHub)" <gi...@apache.org>.
lsq27 commented on PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#issuecomment-1680778028
> I don't really see what's the point to trace the runner, Spring runners are usually one-off tasks. Can you share why we want to trace them?
The feature was inspired by the [spring-scheduled-annotation-plugin](https://github.com/apache/skywalking-java/tree/main/apm-sniffer/apm-sdk-plugin/spring-plugins/scheduled-annotation-plugin). Spring runner can be considered a special scheduled task triggered only once after the SpringApplication has started.
Asuming that an application needs access several services via HTTP or RPC in Spring runners, spans can be integrated in one segment with this plugin, otherwise each span will be in different segments. This plugin can show which class send the requests like `spring-scheduled-annotation-plugin` does.
The feature can be used to improve the tracing of Spring Boot. Since this feature does only a samll thing at the beginning of application, whether the feature should be made a stand alone plugin or a part of so-called spring-boot-plugin in which the code about Spring Boot can be put?
before

after

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] kezhenxu94 commented on pull request #594: Add Spring Runner plugin
Posted by "kezhenxu94 (via GitHub)" <gi...@apache.org>.
kezhenxu94 commented on PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#issuecomment-1679771683
I don't really see what's the point to trace the runner, Spring runners are basically one-off tasks. Can you share why we want to trace them?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] lsq27 commented on a diff in pull request #594: Add Spring Runner plugin
Posted by "lsq27 (via GitHub)" <gi...@apache.org>.
lsq27 commented on code in PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#discussion_r1296113349
##########
apm-sniffer/apm-sdk-plugin/spring-plugins/runner-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/runner/RunnerMethodInterceptor.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.spring.runner;
+
+import java.lang.reflect.Method;
+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.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;
+
+/**
+ * Record the Spring runner task local span.
+ */
+public class RunnerMethodInterceptor implements InstanceMethodsAroundInterceptor {
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ String operationName = ComponentsDefine.SPRING_RUNNER.getName() + "/" + allArguments[0].getClass().getName();
+ AbstractSpan span = ContextManager.createLocalSpan(operationName);
+ Tags.LOGIC_ENDPOINT.set(span, Tags.VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT);
Review Comment:
I have a SpringApplication with complex interactions with other services in CommandLineRunner. Skywalking show many segments at this situation and I try to integrate them into one segment according to code in `spring-scheduled-annotation-plugin`.
It's my fault to add Logic Endpoint here, the runner only run once.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on pull request #594: Add Spring Runner plugin
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#issuecomment-1680796463
How to trigger a runner? Is it always an one time task or repeatable triggered?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] lsq27 commented on a diff in pull request #594: Add Spring Runner plugin
Posted by "lsq27 (via GitHub)" <gi...@apache.org>.
lsq27 commented on code in PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#discussion_r1296113349
##########
apm-sniffer/apm-sdk-plugin/spring-plugins/runner-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/runner/RunnerMethodInterceptor.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.spring.runner;
+
+import java.lang.reflect.Method;
+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.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;
+
+/**
+ * Record the Spring runner task local span.
+ */
+public class RunnerMethodInterceptor implements InstanceMethodsAroundInterceptor {
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ String operationName = ComponentsDefine.SPRING_RUNNER.getName() + "/" + allArguments[0].getClass().getName();
+ AbstractSpan span = ContextManager.createLocalSpan(operationName);
+ Tags.LOGIC_ENDPOINT.set(span, Tags.VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT);
Review Comment:
I have a SpringApplication with complex interactions with other services in CommandLineRunner. Skywalking show many segments at this situation and I try to integrate them into one segment according to code in `spring-scheduled-annotation-plugin`.
It's my fault to add Logic Endpoint here, the runners only run once.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] lsq27 closed pull request #594: Add Spring Runner plugin
Posted by "lsq27 (via GitHub)" <gi...@apache.org>.
lsq27 closed pull request #594: Add Spring Runner plugin
URL: https://github.com/apache/skywalking-java/pull/594
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on pull request #594: Add Spring Runner plugin
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#issuecomment-1682389609
> So it is possible that a application is ready to accept user traffic but the agent can not trace the user access until it is connected with backend? If so, this plugin can not work sometimes.
There is no guarantee. The agent only works when connected. So, who would come first is not a certain thing.
We are not `can't`, we `choose don't` to protect the user app memory.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] lsq27 commented on pull request #594: Add Spring Runner plugin
Posted by "lsq27 (via GitHub)" <gi...@apache.org>.
lsq27 commented on PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#issuecomment-1682395391
> @lsq27 Any feedback about the use case concern.
No more use case.
Spring might implement runner through Spring Scheduled Task and then `spring-scheduled-annotation-plugin` can cover this use case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] lsq27 commented on pull request #594: Add Spring Runner plugin
Posted by "lsq27 (via GitHub)" <gi...@apache.org>.
lsq27 commented on PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#issuecomment-1680873780
> How to trigger a runner? Is it always an one time task or repeatable triggered?
According to [Spring](https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.spring-application.command-line-runner)
> If you need to run some specific code once the SpringApplication has started, you can implement the ApplicationRunner or CommandLineRunner interfaces. Both interfaces work in the same way and offer a single run method, which is called just before SpringApplication.run(…) completes.
Runners only run once in order after the application starts accepting traffic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-java] wu-sheng commented on pull request #594: Add Spring Runner plugin
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #594:
URL: https://github.com/apache/skywalking-java/pull/594#issuecomment-1681395163
If this is a one time running, especially on booting stage, I am highly doubt whether agent always monitors this.
The agent would not work until it is connected with backend, but the runner could have finished by then.
SkyWalking is monitoring server style application running status, rather than booting details.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org