From 1ed179c0bd7f1b179e83a33c024c2a8c3e1c8f36 Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Fri, 10 Jan 2020 19:51:42 +0800 Subject: [PATCH] Stop profiling task when backend doesn't support it (#4213) --- .../core/profile/ProfileTaskQueryService.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/profile/ProfileTaskQueryService.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/profile/ProfileTaskQueryService.java index ef7fdb450..5cca040bf 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/profile/ProfileTaskQueryService.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/profile/ProfileTaskQueryService.java @@ -19,6 +19,8 @@ package org.apache.skywalking.apm.agent.core.profile; import io.grpc.Channel; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; import org.apache.skywalking.apm.agent.core.boot.BootService; import org.apache.skywalking.apm.agent.core.boot.DefaultImplementor; import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory; @@ -73,7 +75,17 @@ public class ProfileTaskQueryService implements BootService, Runnable, GRPCChann Commands commands = profileTaskBlockingStub.withDeadlineAfter(GRPC_UPSTREAM_TIMEOUT, TimeUnit.SECONDS).getProfileTaskCommands(builder.build()); ServiceManager.INSTANCE.findService(CommandService.class).receiveCommand(commands); } catch (Throwable t) { - logger.error(t, "query profile task from Collector fail.", t); + if (!(t instanceof StatusRuntimeException)) { + logger.error(t, "query profile task from Collector fail.", t); + return; + } + final StatusRuntimeException statusRuntimeException = (StatusRuntimeException) t; + if (statusRuntimeException.getStatus().getCode() == Status.Code.UNIMPLEMENTED) { + logger.warn("Backend doesn't support profiling, profiling will be disabled"); + if (getTaskListFuture != null) { + getTaskListFuture.cancel(true); + } + } } } }