AARCH64 APM Java Client Support

Kibana version: latest on ECS

Elasticsearch version: latest on ECS

APM Server version: latest on ECS

APM Agent language and version: 1.18.1

Steps to reproduce:

  1. try and run a jar with APM client on a aarch64 box (such as AWS c6g/r6g/m6g instances)

Provide logs and/or server output (if relevant):

java.lang.IllegalStateException: It is likely that /usr/bin is not an executable location. Consider setting the profiling_inferred_spans_lib_directory property to a directory on a partition that allows execution
	at co.elastic.apm.agent.profiler.asyncprofiler.AsyncProfiler.getInstance(AsyncProfiler.java:77) ~[?:?]
	at co.elastic.apm.agent.profiler.SamplingProfiler.profile(SamplingProfiler.java:386) ~[?:?]
	at co.elastic.apm.agent.profiler.SamplingProfiler.run(SamplingProfiler.java:367) [?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
	at java.lang.Thread.run(Thread.java:832) [?:?]
Caused by: java.lang.UnsatisfiedLinkError: /usr/bin/libasyncProfiler-linux-arm-672c6dfb97228a24cd9de46d11a995ed.so: /usr/bin/libasyncProfiler-linux-arm-672c6dfb97228a24cd9de46d11a995ed.so: wrong ELF class: ELFCLASS32 (Possible cause: can't load ARM .so on a AARCH64 platform)
	at java.lang.ClassLoader$NativeLibrary.load0(Native Method) ~[?:?]
	at java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2452) ~[?:?]
	at java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2508) ~[?:?]
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2704) ~[?:?]
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2637) ~[?:?]
	at java.lang.Runtime.load0(Runtime.java:745) ~[?:?]
	at java.lang.System.load(System.java:1871) ~[?:?]
	at co.elastic.apm.agent.profiler.asyncprofiler.AsyncProfiler.loadNativeLibrary(AsyncProfiler.java:98) ~[?:?]
	at co.elastic.apm.agent.profiler.asyncprofiler.AsyncProfiler.getInstance(AsyncProfiler.java:75) ~[?:?]
	... 8 more

fix would be adding another library to that, compiled on a aarch64 chip

Did you try the suggested solution? -

See profiling_inferred_spans_lib_directory for details.

Also, did you enabled the sampling profiler using the profiling_inferred_spans_enabled option or did you used the default settings ?

Did you try the suggested solution? -

Yes.

After trying a few directories I knew to be executable and getting that same message (the default was /tmp), I noticed the following in that stack trace:

Caused by: java.lang.UnsatisfiedLinkError: /usr/bin/libasyncProfiler-linux-arm-672c6dfb97228a24cd9de46d11a995ed.so: /usr/bin/libasyncProfiler-linux-arm-672c6dfb97228a24cd9de46d11a995ed.so: wrong ELF class: ELFCLASS32 (Possible cause: can't load ARM .so on a AARCH64 platform)

This is enabled via ELASTIC_APM_PROFILING_INFERRED_SPANS_ENABLED=true.

Thanks for reporting this, async-profiler should support aarch64, thus I've opened an issue. You can subscribe to it for updates.

Also which OS/distribution are you using ? That might be useful to help reproduce it.

Thanks for reporting this, async-profiler should support aarch64, thus I've opened an issue. You can subscribe to it for updates.
Thanks!

Also which OS/distribution are you using ?
Amazon Linux 2

Also, could you try to use the standalone async-profiler directly to see if that makes a difference ?

Trying both arm and musl variants sounds relevant in this case.

@likewhatevs Please download this snapshot build and see if you can use the sampling profiler on your aarch64 box with it.

@likewhatevs Did you have a chance to test it?

Better test this snapshot, where I applied a minor change to the OS architecture lookup.