-
Notifications
You must be signed in to change notification settings - Fork 820
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
Publish Jar (with embedded native agent) to Maven central #93
Comments
OK, it would be nice, if someone volunteered to help with this. |
I may help with jar packing and API in my spare time. But I have never published jars to central personally, that needs an experienced one |
I can do the publishing part. |
Some other issues popped during my experience with async-profiler, one feature I hope Java API has: @apangin what do you think? If this seems ok. I will try to send a PR. And Let's keep this issue open for a while |
Java API returns profiling data as a String, then you do whatever you want with this String: write to a file etc. |
Yeah, I know, but that requires wrapper code to flush the output into file. If we can flush output to file, the execute API can be used as same as Java Agent(or Attach)'s options. |
OK. Now if |
Thanks, it works as expected after I check the master branch. However my old approach was persisting execute's argument into vmEntry's internal _agent_args: so it's dumped automatically at JVM exit. |
I would argue that Java API should not modify global arguments designed primarily for the agent loaded at start-up. At Java level an application can still use Java mechanisms such as Shutdown Hook. |
Yeah, that's a fair point. It's ugly to modify |
Adding
to |
@jesperpedersen Agree |
How would you load the native library? OS-dependently export |
Hi |
@apangin I've seen your review remarks as #365 of @JigarJoshi PR. I have following idea to fulfill your requirements:
Thanks to such approach it would be easily to integrate mavenized async-profiler with IoC (i.e. Spring). I can imagine that someone would need to import on classpath I can either continue work on #365 PR or create brand new branch. Remarks: |
@wyhasany Thank you for working on this. The plans sounds good to me. I'm only not sure what you mean by "enumeration param representing one of native's library jar"? Can you give an example please? |
@apangin First of all thank you for your feedback, I can start work now 👍 Enum can looks like as following: enum NativeJarLibrary {
LINUX_X64_1_8_2("api.one.profiler.Linux64_1_8_2"),
LINUX_X86_1_8_2("api.one.profiler.Linux86_1_8_2"),
LINUX_MUSL_X64_1_8_2("api.one.profiler.LinuxMusl64_1_8_2"),
LINUX_ARM_1_8_2("api.one.profiler.LinuxArm_1_8_2"),
LINUX_AARCH64_1_8_2("api.one.profiler.LinuxAarch64_1_8_2"),
MACOS_X64_1_8_2("api.one.profiler.MacOsX64_1_8_2"),
MACOS_X64_2_0_0("api.one.profiler.MacOsX64_2_0_0"),
LINUX_X64_2_0_0("api.one.profiler.Linux64_2_0_0");
private String clazzNextToNativeLibrary;
NativeJarLibrary(String clazzNextToNativeLibrary) {
this.clazzNextToNativeLibrary = clazzNextToNativeLibrary;
}
Class<?> classNextToNativeLibrary(ClassLoader classLoader) {
if (classLoader != null) {
return getClass(classLoader);
} else {
return getClass(NativeJarLibrary.class.getClassLoader());
}
}
private Class<?> getClass(ClassLoader classLoader) {
try {
return Class.forName(clazzNextToNativeLibrary, true, classLoader);
} catch (ClassNotFoundException e) {
//log warn
return null;
}
}
} based on class we can find native library. Current API then could be extended with following method: + public static AsyncProfiler getInstance(NativeJarLibrary nativeJarLibrary) any client can call that |
In the Elastic APM Java agent, we bundle async-profiler as a resource and load it depending on the system it's running on: https://github.com/elastic/apm-agent-java/blob/f9a1bfd6a15c9c8e2bb6512a6973375a78ebb97d/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/asyncprofiler/AsyncProfiler.java#L94-L121 Could that approach be an option for the official async-profiler jar? |
Netty project uses https://github.com/trustin/os-maven-plugin and this is the best solution I have seen in Java world for detecting the OS and architecture and to decide what extension to produce at artifact build time and what dependency to download when using a third party library. |
@felixbarny There are two differents:
@martin-g Thank you for your recommendation. I don't know |
@wyhasany TBH, I don't see much value in enumerating native libraries and letting developers choose one themselves.
|
@apangin ok. I'm going to do it as you wish :) |
Never mind - it looks like I need to do the routine myself anyway, in order to be able to make releases on Maven Central.
It does not include agent library though. This will be only included in v2.0. |
FWIW, a minor datapoint: clj-async-profiler does exactly what @felixbarny suggested – extracting the native binary into a temp directory at runtime and loading it with |
Some hardened systems are configured so that they don't run binaries from temp. A workaround for that would be to let users define the target folder. That can be one through a system property, for example. But temp is still a good default, I think. |
Is there an estimated available time? |
I don't have an estimate, sorry. The task is pretty high on my list, but there are other current requests from business. |
@apangin I saw v2.0 has been released several days ago, seems this feature is absent, any update for future plan? |
@pan3793 The task is in the nearest plans. No specific commitments though. |
@apangin Sorry for bothering you again, but may I know any updates for the plan? |
@pan3793 The plans haven't changed: I'll eventually get to this, I just don't usually commit myself to particular deadlines for the community issues. The reliable way to get something done sooner is to purchase a support contract. Seriously, if your or your company's work depends on a specific async-profiler task, b2b approach works best. |
Sharing here some extra knowledge: there exists https://github.com/scijava/native-lib-loader that provide a way to load a native library directly from a jar (without having to go through extracting it in a temp file, etc). |
Also another good source of information about packaging native libraries is https://github.com/maven-nar/nar-maven-plugin (which is a plugin to compile and package native libs inside a jar). |
That sounds reasonable, I'm going to work on it in the following days. My idea is to build async-profiler automatically on multiple platforms (leveraging the SapMachine.io build servers), creating different JARs for all platforms and creating on single JAR which combines all those. The approach from https://github.com/elastic/apm-agent-java/blob/f9a1bfd6a15c9c8e2bb6512a6973375a78ebb97d/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/asyncprofiler/AsyncProfiler.java#L94-L121 seems reasonable and simple. |
Published async-profiler 2.9 with the embedded agent for linux-x64, linux-arm64 and macos:
Alternatively, look at ap-loader project - it creates a single JAR that can be used to run async-profiler programmatically or as |
excellent @apangin! |
Some ideas about the Java API:
The text was updated successfully, but these errors were encountered: