-
Notifications
You must be signed in to change notification settings - Fork 622
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
Support async profiler feature #720
Conversation
4f73937
to
5adec9b
Compare
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
Show resolved
Hide resolved
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
Outdated
Show resolved
Hide resolved
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
Outdated
Show resolved
Hide resolved
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
Outdated
Show resolved
Hide resolved
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
Outdated
Show resolved
Hide resolved
...core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTask.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerDataSender.java
Outdated
Show resolved
Hide resolved
Pls fix CI |
…/apm/agent/core/conf/Config.java Co-authored-by: Jiajing LU <[email protected]>
…/apm/agent/core/conf/Config.java Co-authored-by: Jiajing LU <[email protected]>
…/apm/agent/core/conf/Config.java Co-authored-by: Jiajing LU <[email protected]>
…/apm/agent/core/conf/Config.java Co-authored-by: Jiajing LU <[email protected]>
* Wait briefly to see if the server can receive the jfr. If the server cannot receive it, onError will be triggered. | ||
* Then we wait for a while (waiting for the server to send onError) and then decide whether to send the jfr file. | ||
*/ | ||
Thread.sleep(500); |
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.
@wu-sheng In the current design, the Java Agent has to wait after the first request in order to determine whether the OAP accepts the following data transfer. This is a kind of negotiation.
WDYT?
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.
If you need to wait for the server, you should change AsyncProfilerTask
service to dual streaming, and the response needs to be a kind of ack
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.
500ms
can't guarantee anything AFAIK.
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.
If you need to wait for the server, you should change
AsyncProfilerTask
service to dual streaming, and the response needs to be a kind of ack
Sure. Let's use dual streaming @zhengziyi0117
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.
Note, in this case, Command should not be the response anymore.
*/ | ||
Thread.sleep(500); | ||
|
||
// Is it possible to upload jfr? |
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.
What does this comment mean?
pom.xml
Outdated
<dependency> | ||
<groupId>tools.profiler</groupId> | ||
<artifactId>async-profiler</artifactId> | ||
<version>${async-profiler.version}</version> | ||
</dependency> |
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.
Please move this the last one rather than the first.
pom.xml
Outdated
@@ -87,6 +87,7 @@ | |||
|
|||
<!-- core lib dependency --> | |||
<bytebuddy.version>1.14.9</bytebuddy.version> | |||
<async-profiler.version>3.0</async-profiler.version> |
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.
Please move this the last one rather than the first.
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.
LGTM if all the current comments are resolved
|
||
@Override | ||
public void shutdown() throws Throwable { | ||
scheduledFuture.cancel(true); |
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.
you have to check NULL!
Commands commands = asyncProfilerTaskBlockingStub.withDeadlineAfter(GRPC_UPSTREAM_TIMEOUT, TimeUnit.SECONDS) | ||
.getAsyncProfilerTaskCommands(query); | ||
ServiceManager.INSTANCE.findService(CommandService.class).receiveCommand(commands); |
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.
You should check service not implemented
error of gRPC, you could try that by connecting v < 10.1 OAP.
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.
Once it is not implemented, the agent should shutdown this part automatically.
apm-sniffer/config/agent.config
Outdated
@@ -164,6 +164,12 @@ profile.duration=${SW_AGENT_PROFILE_DURATION:10} | |||
profile.dump_max_stack_depth=${SW_AGENT_PROFILE_DUMP_MAX_STACK_DEPTH:500} | |||
# Snapshot transport to backend buffer size | |||
profile.snapshot_transport_buffer_size=${SW_AGENT_PROFILE_SNAPSHOT_TRANSPORT_BUFFER_SIZE:4500} | |||
# If true, Async Profiler will be enabled when user creates a new async profiler task, Otherwise it is disabled. |
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.
This comment is not accurate. You hard coded this value as true, so, the default value is TRUE, not disabled. Please update your default value in the codes.
...java/org/apache/skywalking/apm/network/trace/component/command/AsyncProfilerTaskCommand.java
Show resolved
Hide resolved
@DefaultImplementor | ||
public class AsyncProfilerDataSender implements BootService, GRPCChannelListener { | ||
private static final ILog LOGGER = LogManager.getLogger(ProfileSnapshotSender.class); | ||
private static final int DATA_CHUNK_SIZE = 1024 * 1024; |
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.
This should move into config. Don't have to expose through agent.config, but we don't need to hard code this.
status.finished(); | ||
ServiceManager.INSTANCE.findService(GRPCChannelManager.class).reportError(t); |
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.
When onError
, we should output logs.
...rc/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerDataSender.java
Outdated
Show resolved
Hide resolved
|
||
private static final ILog LOGGER = LogManager.getLogger(AsyncProfilerTaskChannelService.class); | ||
|
||
private static final AsyncProfiler ASYNC_PROFILER = AsyncProfiler.getInstance(); |
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.
Please use lazy initialization as much as possible. I am not sure how much effects would this getInstance takes, but as service list is loaded before agent instrumentation, we should load as less code as possible. Otherwise, the instrumentation could fail due to classes have been loaded.
private static final String SUCCESS_RESULT = "Profiling started\n"; | ||
|
||
// profile executor thread pool, only running one thread | ||
private static final ScheduledExecutorService ASYNC_PROFILER_EXECUTOR = Executors.newSingleThreadScheduledExecutor( |
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.
Same here, please initialize later in the process.
…/apm/agent/core/asyncprofiler/AsyncProfilerDataSender.java Co-authored-by: 吴晟 Wu Sheng <[email protected]>
...va/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTaskExecutionService.java
Outdated
Show resolved
Hide resolved
...va/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTaskExecutionService.java
Outdated
Show resolved
Hide resolved
…/apm/agent/core/asyncprofiler/AsyncProfilerTaskExecutionService.java Co-authored-by: 吴晟 Wu Sheng <[email protected]>
…/apm/agent/core/asyncprofiler/AsyncProfilerTaskExecutionService.java Co-authored-by: 吴晟 Wu Sheng <[email protected]>
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.
LGTM
return; | ||
} | ||
final StatusRuntimeException statusRuntimeException = (StatusRuntimeException) t; | ||
if (statusRuntimeException.getStatus().getCode() == Status.Code.UNIMPLEMENTED) { |
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.
Please use Status.Code.UNIMPLEMENTED.equals
. It is safer.
Integrate async profiler performance analysis function in Java
CHANGES
log.