You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2022/01/02 06:02:03 UTC
[incubator-shenyu] branch master updated: [type: feature]: add jaeger in agent. (#2693)
This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 96eca76 [type: feature]: add jaeger in agent. (#2693)
96eca76 is described below
commit 96eca76631c5019a6eb0eff6f3f1af39180b29c1
Author: YuI <13...@users.noreply.github.com>
AuthorDate: Sun Jan 2 14:01:57 2022 +0800
[type: feature]: add jaeger in agent. (#2693)
* [type:refactor]: modify the packaging path about agent.
* [type:refactor]: close maven-assembly-plugin
* [type: refactor]: resolve agent not work.
* [type: refactor]: close maven-assembly-plugin
* [type: refactor]: checkstyle
* [type: refactor]: introduce bytebuddy dependencies for classloader.
* [type: refactor]: checkstyle
* [type: feature]: add jaeger in agent.
* [type: feature]: add jaeger in agent.
* [type: refactor]: checkstyle
* [type: fix]: merge conflict.
* [type: refactor]: remove extra libs and don't let Map expand.
* [type: feature]: add ResponsePlugin.
Co-authored-by: 艺铭 <yi...@perfma.com>
---
.../agent/api/handler/InstanceMethodHandler.java | 5 +-
shenyu-agent/shenyu-agent-core/pom.xml | 1 +
.../interceptor/InstanceMethodInterceptor.java | 2 +-
.../common/TracingAgentPluginDefinition.java | 3 +-
.../jaeger/handler/JaegerGlobalPluginHandler.java | 52 ++++--
.../jaeger/handler/JaegerPluginCommonHandler.java | 83 +++++++++
.../handler/JaegerResponsePluginHandler.java | 54 ------
.../tracing/jaeger/span/JaegerErrorSpan.java | 2 +-
.../tracing/jaeger/span/JaegerSpanManager.java | 103 +++++++++++
.../zipkin/handler/ZipkinGlobalPluginHandler.java | 4 +-
.../handler/ZipkinResponsePluginHandler.java | 4 +-
.../src/main/resources/conf/tracing-point.yaml | 197 ++++++++++++++++++++-
.../annotation/impl/DubboTestServiceImpl.java | 6 +-
.../service/xml/TestApacheDubboXmlApplication.java | 2 +-
.../controller/ShenyuClientPathController.java | 5 +-
.../controller/SpringMvcMappingPathController.java | 2 +-
.../motan/service/impl/MotanDemoServiceImpl.java | 3 +-
.../examples/springcloud/dto/EntityResult.java | 38 +++-
18 files changed, 473 insertions(+), 93 deletions(-)
diff --git a/shenyu-agent/shenyu-agent-api/src/main/java/org/apache/shenyu/agent/api/handler/InstanceMethodHandler.java b/shenyu-agent/shenyu-agent-api/src/main/java/org/apache/shenyu/agent/api/handler/InstanceMethodHandler.java
index ec35855..907dff2 100644
--- a/shenyu-agent/shenyu-agent-api/src/main/java/org/apache/shenyu/agent/api/handler/InstanceMethodHandler.java
+++ b/shenyu-agent/shenyu-agent-api/src/main/java/org/apache/shenyu/agent/api/handler/InstanceMethodHandler.java
@@ -44,9 +44,12 @@ public interface InstanceMethodHandler {
* @param target the target
* @param method the method
* @param args the args
+ * @param methodResult {@linkplain MethodResult}
* @param result the result
+ * @return result
*/
- default void after(final TargetObject target, final Method method, final Object[] args, final MethodResult result) {
+ default Object after(final TargetObject target, final Method method, final Object[] args, final MethodResult methodResult, final Object result) {
+ return result;
}
/**
diff --git a/shenyu-agent/shenyu-agent-core/pom.xml b/shenyu-agent/shenyu-agent-core/pom.xml
index 59e1b55..a2317f5 100644
--- a/shenyu-agent/shenyu-agent-core/pom.xml
+++ b/shenyu-agent/shenyu-agent-core/pom.xml
@@ -34,6 +34,7 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
diff --git a/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/bytebuddy/interceptor/InstanceMethodInterceptor.java b/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/bytebuddy/interceptor/InstanceMethodInterceptor.java
index 0ed91c4..0bb968b 100644
--- a/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/bytebuddy/interceptor/InstanceMethodInterceptor.java
+++ b/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/bytebuddy/interceptor/InstanceMethodInterceptor.java
@@ -89,7 +89,7 @@ public class InstanceMethodInterceptor {
}
} finally {
try {
- handler.after(instance, method, args, methodResult);
+ result = handler.after(instance, method, args, methodResult, result);
// CHECKSTYLE:OFF
} catch (final Throwable ex) {
// CHECKSTYLE:ON
diff --git a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-common/src/main/java/org/apache/shenyu/agent/plugin/tracing/common/TracingAgentPluginDefinition.java b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-common/src/main/java/org/apache/shenyu/agent/plugin/tracing/common/TracingAgentPluginDefinition.java
index 2850001..8504d4f 100644
--- a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-common/src/main/java/org/apache/shenyu/agent/plugin/tracing/common/TracingAgentPluginDefinition.java
+++ b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-common/src/main/java/org/apache/shenyu/agent/plugin/tracing/common/TracingAgentPluginDefinition.java
@@ -94,6 +94,7 @@ public final class TracingAgentPluginDefinition extends AbstractAgentPluginDefin
builder.onConstructor(ElementMatchers.namedOneOf(constructorPoints)).handlers(handlers).build();
}
return builder;
- }).collect(Collectors.toList());
+ })
+ .collect(Collectors.toList());
}
}
diff --git a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerGlobalPluginHandler.java b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerGlobalPluginHandler.java
index e0cb00b..b8b30ab 100644
--- a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerGlobalPluginHandler.java
+++ b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerGlobalPluginHandler.java
@@ -19,34 +19,64 @@ package org.apache.shenyu.agent.plugin.tracing.jaeger.handler;
import io.opentracing.Span;
import io.opentracing.tag.Tags;
-import io.opentracing.util.GlobalTracer;
import org.apache.shenyu.agent.api.entity.MethodResult;
import org.apache.shenyu.agent.api.entity.TargetObject;
import org.apache.shenyu.agent.api.handler.InstanceMethodHandler;
import org.apache.shenyu.agent.plugin.tracing.jaeger.constant.JaegerConstants;
-import org.apache.shenyu.agent.plugin.tracing.jaeger.span.JaegerErrorSpan;
+import org.apache.shenyu.agent.plugin.tracing.jaeger.span.JaegerSpanManager;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
/**
* The type Jaeger global plugin handler.
*/
public final class JaegerGlobalPluginHandler implements InstanceMethodHandler {
-
+
@Override
public void before(final TargetObject target, final Method method, final Object[] args, final MethodResult result) {
- Span scope = GlobalTracer.get().buildSpan(JaegerConstants.ROOT_SPAN)
- .withTag(Tags.COMPONENT.getKey(), JaegerConstants.NAME).start();
- target.setContext(scope);
+ final ServerWebExchange exchange = (ServerWebExchange) args[0];
+ final JaegerSpanManager jaegerSpanManager = (JaegerSpanManager) exchange.getAttributes()
+ .getOrDefault(JaegerConstants.ROOT_SPAN, new JaegerSpanManager());
+
+ Map<String, String> tagMap = new HashMap<>(4);
+ tagMap.put(Tags.COMPONENT.getKey(), JaegerConstants.NAME);
+ tagMap.put(Tags.HTTP_URL.getKey(), exchange.getRequest().getURI().toString());
+ Optional.ofNullable(exchange.getRequest().getMethod())
+ .ifPresent(v -> tagMap.put(Tags.HTTP_STATUS.getKey(), v.toString()));
+
+ Span span = jaegerSpanManager.add(JaegerConstants.ROOT_SPAN, tagMap);
+ exchange.getAttributes().put(JaegerConstants.RESPONSE_SPAN, jaegerSpanManager);
+ target.setContext(span);
}
-
+
@Override
- public void after(final TargetObject target, final Method method, final Object[] args, final MethodResult result) {
- ((Span) target.getContext()).finish();
+ public Object after(final TargetObject target, final Method method, final Object[] args, final MethodResult methodResult, final Object result) {
+ Span span = (Span) target.getContext();
+ ServerWebExchange exchange = (ServerWebExchange) args[0];
+ JaegerSpanManager manager = (JaegerSpanManager) exchange.getAttributes().get(JaegerConstants.ROOT_SPAN);
+
+ if (result instanceof Mono) {
+ return ((Mono) result).doFinally(s -> {
+ manager.finish(span, exchange);
+ });
+ }
+
+ manager.finish(span, exchange);
+ return result;
}
-
+
@Override
public void onThrowing(final TargetObject target, final Method method, final Object[] args, final Throwable throwable) {
- JaegerErrorSpan.setError(GlobalTracer.get().activeSpan(), throwable);
+ Span span = (Span) target.getContext();
+
+ ServerWebExchange exchange = (ServerWebExchange) args[0];
+ JaegerSpanManager manager = (JaegerSpanManager) exchange.getAttributes().get(JaegerConstants.ROOT_SPAN);
+
+ manager.error(span, exchange, throwable);
}
}
diff --git a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerPluginCommonHandler.java b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerPluginCommonHandler.java
new file mode 100644
index 0000000..3f727ae
--- /dev/null
+++ b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerPluginCommonHandler.java
@@ -0,0 +1,83 @@
+/*
+ * 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.shenyu.agent.plugin.tracing.jaeger.handler;
+
+import io.opentracing.Span;
+import io.opentracing.tag.Tags;
+import org.apache.shenyu.agent.api.entity.MethodResult;
+import org.apache.shenyu.agent.api.entity.TargetObject;
+import org.apache.shenyu.agent.api.handler.InstanceMethodHandler;
+import org.apache.shenyu.agent.plugin.tracing.jaeger.constant.JaegerConstants;
+import org.apache.shenyu.agent.plugin.tracing.jaeger.span.JaegerSpanManager;
+import org.apache.shenyu.common.utils.GsonUtils;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The type Jaeger for shenyu plugins' common handler.
+ */
+public final class JaegerPluginCommonHandler implements InstanceMethodHandler {
+
+ @Override
+ public void before(final TargetObject target, final Method method, final Object[] args, final MethodResult result) {
+ final ServerWebExchange exchange = (ServerWebExchange) args[0];
+ final JaegerSpanManager jaegerSpanManager = (JaegerSpanManager) exchange.getAttributes()
+ .getOrDefault(JaegerConstants.ROOT_SPAN, new JaegerSpanManager());
+
+ Map<String, String> tagMap = new HashMap<>(8);
+ tagMap.put(Tags.COMPONENT.getKey(), JaegerConstants.NAME);
+ tagMap.put(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
+ for (int i = 2; i < args.length; i++) {
+ tagMap.put(args[i].getClass().getName(), GsonUtils.getGson().toJson(args[i]));
+ }
+
+ Span span = jaegerSpanManager.add(method.getDeclaringClass().getSimpleName(), tagMap);
+ exchange.getAttributes().put(JaegerConstants.RESPONSE_SPAN, jaegerSpanManager);
+ target.setContext(span);
+ }
+
+ @Override
+ public Object after(final TargetObject target, final Method method, final Object[] args, final MethodResult methodResult, final Object result) {
+ Span span = (Span) target.getContext();
+ ServerWebExchange exchange = (ServerWebExchange) args[0];
+ JaegerSpanManager manager = (JaegerSpanManager) exchange.getAttributes().get(JaegerConstants.ROOT_SPAN);
+
+ if (result instanceof Mono) {
+ return ((Mono) result).doFinally(s -> {
+ manager.finish(span, exchange);
+ });
+ }
+
+ manager.finish(span, exchange);
+ return result;
+ }
+
+ @Override
+ public void onThrowing(final TargetObject target, final Method method, final Object[] args, final Throwable throwable) {
+ Span span = (Span) target.getContext();
+
+ ServerWebExchange exchange = (ServerWebExchange) args[0];
+ JaegerSpanManager manager = (JaegerSpanManager) exchange.getAttributes().get(JaegerConstants.ROOT_SPAN);
+
+ manager.error(span, exchange, throwable);
+ }
+}
diff --git a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerResponsePluginHandler.java b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerResponsePluginHandler.java
deleted file mode 100644
index 9adc524..0000000
--- a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerResponsePluginHandler.java
+++ /dev/null
@@ -1,54 +0,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.
- */
-
-package org.apache.shenyu.agent.plugin.tracing.jaeger.handler;
-
-import io.opentracing.Span;
-import io.opentracing.tag.Tags;
-import io.opentracing.util.GlobalTracer;
-import org.apache.shenyu.agent.api.entity.MethodResult;
-import org.apache.shenyu.agent.api.entity.TargetObject;
-import org.apache.shenyu.agent.api.handler.InstanceMethodHandler;
-import org.apache.shenyu.agent.plugin.tracing.jaeger.constant.JaegerConstants;
-import org.apache.shenyu.agent.plugin.tracing.jaeger.span.JaegerErrorSpan;
-
-import java.lang.reflect.Method;
-
-/**
- * The type Jaeger response plugin handler.
- */
-public final class JaegerResponsePluginHandler implements InstanceMethodHandler {
-
- @Override
- public void before(final TargetObject target, final Method method, final Object[] args, final MethodResult result) {
- Span span = GlobalTracer.get().buildSpan(JaegerConstants.RESPONSE_SPAN)
- .withTag(Tags.COMPONENT.getKey(), JaegerConstants.NAME)
- .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
- .start();
- target.setContext(span);
- }
-
- @Override
- public void after(final TargetObject target, final Method method, final Object[] args, final MethodResult result) {
- ((Span) target.getContext()).finish();
- }
-
- @Override
- public void onThrowing(final TargetObject target, final Method method, final Object[] args, final Throwable throwable) {
- JaegerErrorSpan.setError(GlobalTracer.get().activeSpan(), throwable);
- }
-}
diff --git a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerErrorSpan.java b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerErrorSpan.java
index c109c99..b51fd3c 100644
--- a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerErrorSpan.java
+++ b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerErrorSpan.java
@@ -36,7 +36,7 @@ public final class JaegerErrorSpan {
* @param cause failure cause of span
*/
public static void setError(final Span span, final Throwable cause) {
- span.setTag(Tags.ERROR.getKey(), true).log(System.currentTimeMillis(), getReason(cause));
+ span.setTag(Tags.ERROR.getKey(), true).log(System.currentTimeMillis() * 1000, getReason(cause));
}
private static Map<String, ?> getReason(final Throwable cause) {
diff --git a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerSpanManager.java b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerSpanManager.java
new file mode 100644
index 0000000..4d741fe
--- /dev/null
+++ b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerSpanManager.java
@@ -0,0 +1,103 @@
+/*
+ * 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.shenyu.agent.plugin.tracing.jaeger.span;
+
+import io.opentracing.Scope;
+import io.opentracing.Span;
+import io.opentracing.Tracer;
+import io.opentracing.util.GlobalTracer;
+import org.apache.shenyu.agent.plugin.tracing.jaeger.constant.JaegerConstants;
+import org.springframework.web.server.ServerWebExchange;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class JaegerSpanManager {
+
+ private final List<Scope> scopeList;
+
+ private volatile Span lastSpan;
+
+ private final AtomicInteger count;
+
+ /**
+ * construct to init.
+ */
+ public JaegerSpanManager() {
+ scopeList = new LinkedList<>();
+ count = new AtomicInteger(0);
+ }
+
+ /**
+ * add span message to create new span.
+ *
+ * @param buildSpan span name
+ * @param tagMap span tag
+ * @return {@linkplain Span}
+ */
+ public Span add(final String buildSpan, final Map<String, String> tagMap) {
+ Tracer tracer = GlobalTracer.get();
+
+ Tracer.SpanBuilder spanBuilder = tracer.buildSpan(buildSpan);
+ if (Objects.nonNull(lastSpan)) {
+ spanBuilder.asChildOf(lastSpan);
+ } else {
+ spanBuilder.ignoreActiveSpan();
+ }
+
+ tagMap.forEach(spanBuilder::withTag);
+ Span span = spanBuilder.start();
+ Scope scope = tracer.scopeManager().activate(span);
+
+ lastSpan = span;
+ count.incrementAndGet();
+ scopeList.add(scope);
+
+ return lastSpan;
+ }
+
+ /**
+ * finis span record.
+ *
+ * @param span {@linkplain Span}
+ * @param exchange webflux server object
+ */
+ public void finish(final Span span, final ServerWebExchange exchange) {
+ span.finish();
+ if (count.decrementAndGet() == 0) {
+ scopeList.forEach(Scope::close);
+ exchange.getAttributes().remove(JaegerConstants.RESPONSE_SPAN);
+ }
+ }
+
+ /**
+ * record error.
+ *
+ * @param span {@linkplain Span}
+ * @param exchange webflux server object
+ * @param throwable error
+ */
+ public void error(final Span span, final ServerWebExchange exchange, final Throwable throwable) {
+ JaegerErrorSpan.setError(span, throwable);
+ finish(span, exchange);
+ }
+
+}
diff --git a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-zipkin/src/main/java/org/apache/shenyu/agent/plugin/tracing/zipkin/handler/ZipkinGlobalPluginHandler.java b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-zipkin/src/main/java/org/apache/shenyu/agent/plugin/tracing/zipkin/handler/ZipkinGlobalPluginHandler.java
index 8319a27..6b604af 100644
--- a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-zipkin/src/main/java/org/apache/shenyu/agent/plugin/tracing/zipkin/handler/ZipkinGlobalPluginHandler.java
+++ b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-zipkin/src/main/java/org/apache/shenyu/agent/plugin/tracing/zipkin/handler/ZipkinGlobalPluginHandler.java
@@ -34,8 +34,8 @@ public final class ZipkinGlobalPluginHandler implements InstanceMethodHandler {
}
@Override
- public void after(final TargetObject target, final Method method, final Object[] args, final MethodResult result) {
-
+ public Object after(final TargetObject target, final Method method, final Object[] args, final MethodResult methodResult, final Object result) {
+ return result;
}
@Override
diff --git a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-zipkin/src/main/java/org/apache/shenyu/agent/plugin/tracing/zipkin/handler/ZipkinResponsePluginHandler.java b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-zipkin/src/main/java/org/apache/shenyu/agent/plugin/tracing/zipkin/handler/ZipkinResponsePluginHandler.java
index 4de5134..df43f42 100644
--- a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-zipkin/src/main/java/org/apache/shenyu/agent/plugin/tracing/zipkin/handler/ZipkinResponsePluginHandler.java
+++ b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-zipkin/src/main/java/org/apache/shenyu/agent/plugin/tracing/zipkin/handler/ZipkinResponsePluginHandler.java
@@ -34,8 +34,8 @@ public final class ZipkinResponsePluginHandler implements InstanceMethodHandler
}
@Override
- public void after(final TargetObject target, final Method method, final Object[] args, final MethodResult result) {
-
+ public Object after(final TargetObject target, final Method method, final Object[] args, final MethodResult methodResult, final Object result) {
+ return result;
}
@Override
diff --git a/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/tracing-point.yaml b/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/tracing-point.yaml
index efe565e..1268dd2 100644
--- a/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/tracing-point.yaml
+++ b/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/tracing-point.yaml
@@ -21,12 +21,201 @@ pointCuts:
- type: instanceMethod
name: execute
handlers:
- jaeger:
- - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerGlobalPluginHandler
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerGlobalPluginHandler
+ - targetClass: org.apache.shenyu.plugin.context.path.ContextPathPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.divide.DividePlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.alibaba.dubbo.AlibabaDubboPlugin
+ points:
+ - type: instanceMethod
+ name: doDubboInvoker
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.apache.dubbo.ApacheDubboPlugin
+ points:
+ - type: instanceMethod
+ name: doDubboInvoker
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.general.context.GeneralContextPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.grpc.GrpcPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.hystrix.HystrixPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.jwt.JwtPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.logging.LoggingPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.modify.response.ModifyResponsePlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.monitor.MonitorPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.motan.MotanPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.oauth2.OAuth2Plugin
+ points:
+ - type: instanceMethod
+ name: execute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.param.mapping.ParamMappingPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.ratelimiter.RateLimiterPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.redirect.RedirectPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.request.RequestPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.resilience4j.Resilience4JPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
- targetClass: org.apache.shenyu.plugin.response.ResponsePlugin
points:
- type: instanceMethod
name: execute
handlers:
- jaeger:
- - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerResponsePluginHandler
\ No newline at end of file
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.rewrite.RewritePlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.sentinel.SentinelPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.sign.SignPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.sofa.SofaPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.springcloud.SpringCloudPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.tars.TarsPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.uri.URIPlugin
+ points:
+ - type: instanceMethod
+ name: execute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.waf.WafPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.websocket.WebSocketPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ jaeger:
+ - org.apache.shenyu.agent.plugin.tracing.jaeger.handler.JaegerPluginCommonHandler
\ No newline at end of file
diff --git a/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java b/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java
index e00cb3b..2f4e6eb 100644
--- a/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java
+++ b/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java
@@ -23,6 +23,8 @@ import org.apache.shenyu.common.utils.GsonUtils;
import org.apache.shenyu.examples.dubbo.api.entity.DubboTest;
import org.apache.shenyu.examples.dubbo.api.entity.ListResp;
import org.apache.shenyu.examples.dubbo.api.service.DubboTestService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.Random;
@@ -32,11 +34,13 @@ import java.util.Random;
*/
@Service
public class DubboTestServiceImpl implements DubboTestService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DubboTestServiceImpl.class);
@Override
@ShenyuDubboClient(path = "/findById", desc = "Query by Id")
public DubboTest findById(final String id) {
- System.out.println(GsonUtils.getInstance().toJson(RpcContext.getContext().getAttachments()));
+ LOGGER.info(GsonUtils.getInstance().toJson(RpcContext.getContext().getAttachments()));
return new DubboTest(id, "hello world shenyu Apache, findById");
}
diff --git a/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/TestApacheDubboXmlApplication.java b/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/TestApacheDubboXmlApplication.java
index b867d9b..b46bb49 100644
--- a/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/TestApacheDubboXmlApplication.java
+++ b/shenyu-examples/shenyu-examples-dubbo/shenyu-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/TestApacheDubboXmlApplication.java
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.ImportResource;
* Demo show users how to use shenyu-client-apache-dubbo jar in their apache dubbo project.
*/
@SpringBootApplication
-@ImportResource({"classpath:spring-dubbo.xml","classpath:shenyu.xml"})
+@ImportResource({"classpath:spring-dubbo.xml", "classpath:shenyu.xml"})
public class TestApacheDubboXmlApplication {
public static void main(String[] args) {
diff --git a/shenyu-examples/shenyu-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java b/shenyu-examples/shenyu-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java
index 3394711..29d4575 100644
--- a/shenyu-examples/shenyu-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java
+++ b/shenyu-examples/shenyu-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-
package org.apache.shenyu.examples.http.controller;
import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient;
@@ -24,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
- * ShenyuClientPathController
+ * ShenyuClientPathController.
*/
@RestController
public class ShenyuClientPathController {
@@ -32,7 +31,7 @@ public class ShenyuClientPathController {
private static final String HELLO_SUFFIX = "I'm Shenyu-Gateway System. Welcome!";
/**
- * hello
+ * hello.
*
* @return result
*/
diff --git a/shenyu-examples/shenyu-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java b/shenyu-examples/shenyu-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java
index 542fcbc..5298676 100644
--- a/shenyu-examples/shenyu-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java
+++ b/shenyu-examples/shenyu-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java
@@ -23,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
- * SpringMvcMappingPathController
+ * SpringMvcMappingPathController.
*/
@RestController
@ShenyuSpringMvcClient(desc = "spring annotation register")
diff --git a/shenyu-examples/shenyu-examples-motan/shenyu-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/impl/MotanDemoServiceImpl.java b/shenyu-examples/shenyu-examples-motan/shenyu-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/impl/MotanDemoServiceImpl.java
index 655a1b7..dd67b42 100644
--- a/shenyu-examples/shenyu-examples-motan/shenyu-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/impl/MotanDemoServiceImpl.java
+++ b/shenyu-examples/shenyu-examples-motan/shenyu-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/impl/MotanDemoServiceImpl.java
@@ -26,9 +26,10 @@ import org.apache.shenyu.examples.motan.service.MotanDemoService;
*/
@MotanService(export = "demoMotan:8002")
public class MotanDemoServiceImpl implements MotanDemoService {
+
@Override
@ShenyuMotanClient(path = "/hello")
- public String hello(String name) {
+ public String hello(final String name) {
return "hello " + name;
}
}
diff --git a/shenyu-examples/shenyu-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/EntityResult.java b/shenyu-examples/shenyu-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/EntityResult.java
index df09971..81664be 100644
--- a/shenyu-examples/shenyu-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/EntityResult.java
+++ b/shenyu-examples/shenyu-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/EntityResult.java
@@ -21,35 +21,55 @@ package org.apache.shenyu.examples.springcloud.dto;
* EntityResult.
*/
public class EntityResult {
-
+
/**
* code.
*/
private int code;
+
/**
* message.
*/
private String message;
-
- public EntityResult(int code, String message) {
+ public EntityResult(final int code, final String message) {
this.code = code;
this.message = message;
}
-
+
+ /**
+ * getCode.
+ *
+ * @return int
+ */
public int getCode() {
return code;
}
-
- public void setCode(int code) {
+
+ /**
+ * setCode.
+ *
+ * @param code code
+ */
+ public void setCode(final int code) {
this.code = code;
}
-
+
+ /**
+ * getMessage.
+ *
+ * @return message
+ */
public String getMessage() {
return message;
}
-
- public void setMessage(String message) {
+
+ /**
+ * setMessage.
+ *
+ * @param message message
+ */
+ public void setMessage(final String message) {
this.message = message;
}
}