quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.65k stars 2.64k forks source link

dynatrace #6149

Open maxandersen opened 4 years ago

maxandersen commented 4 years ago

Describe the extension Dynatrace supports detailed tracing of both native and java based applications; but out of the box it does not work in native-image. Would be great if by just adding this extension it would be made to work.

As things are now users will have to turn of dynatrace injection completely.

Additional context By default Dynatrace uses an agent and in a kubernetes cluster setup this agent gets injected "blindly" causing errors similar to this:

Detailed message:
Error: Error while collecting implementations of java.lang.Object.finalize() : Unsupported method java.lang.ClassLoader.finalize() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.

Call path from entry point to java.lang.Object.finalize():
no path found from entry point to target method

Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported field java.lang.ClassLoader.dynatrace_initialized is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
at parsing com.oracle.svm.core.jdk.SubstrateRuntimeMXBean$1.run(ManagementSupport.java)
Call path from entry point to com.oracle.svm.core.jdk.SubstrateRuntimeMXBean$1.run():
at com.oracle.svm.core.jdk.SubstrateRuntimeMXBean$1.run(ManagementSupport.java)
at java.lang.Shutdown.runHooks(Shutdown.java:123)
at java.lang.Shutdown.sequence(Shutdown.java:167)
at java.lang.Shutdown.shutdown(Shutdown.java:234)
at com.oracle.svm.core.jdk.RuntimeSupport.shutdown(RuntimeSupport.java:181)
at com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:176)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported field java.lang.ClassLoader.dynatrace_initialized is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
at parsing com.oracle.svm.core.jdk.Target_java_lang_Shutdown$$Lambda$86/1206599267.run(Unknown Source)
Call path from entry point to com.oracle.svm.core.jdk.Target_java_lang_Shutdown$$Lambda$7e59e058057d19c98e156e912f8f45b540afd7b5.run():
at com.oracle.svm.core.jdk.Target_java_lang_Shutdown$$Lambda$86/1206599267.run(Unknown Source)
at java.lang.Shutdown.runHooks(Shutdown.java:123)
at java.lang.Shutdown.sequence(Shutdown.java:167)
at java.lang.Shutdown.shutdown(Shutdown.java:234)
at com.oracle.svm.core.jdk.RuntimeSupport.shutdown(RuntimeSupport.java:181)
at com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:176)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)

Seems this is caused by use of finalizers in dynatrace agent library which is not supported in native-images.

Would be nice if we could have a dynatrace extension that would at minimum work around this issue and remove the offending bits at best to enable just enough of dynatrace that it would work at least somewhat out of the box.

nicolas-vivot commented 2 years ago

Without digging too much, i guess a quarkus extension using the OneAgent SDK is the official and cleaner way to go.

But this extension will have to propose integration with other framework to automatically trace the different layers / calls (database, etc.), or at least an annotation to easy flag what must be traced in the application.

nicolas-vivot commented 2 years ago

If you're only interested into the PurePath (tracing) and/or metrics, the other way is to pass by opentelemetry. The dynatrace agent can receive opentelemetry data, and newer versions of quarkus (don't remember from which major version) are now officially supporting opentelemetry for tracing & metrics if i'm not wrong.

If you are looking for tracing / analytics features more specific to what dynatrace does, then supporting the OneAgent SDK might be better, did not really check what this SDK does when "tracing" the code.