LinShunKang / MyPerf4J

High performance Java APM. Powered by ASM. Try it. Test it. If you feel its better, use it.
BSD 3-Clause "New" or "Revised" License
3.41k stars 540 forks source link

UnsupportedOperationException: This feature requires ASM7 #68

Closed gamefundas closed 3 years ago

gamefundas commented 3 years ago

I am getting the following exception during application startup for several classes and don't see the metrics log getting created. Assuming MyPerf4J failed to initialize because of this error

2021-01-04 14:35:00.132 [MyPerf4J] ERROR [Jetty-68] ProfilingTransformer.transform(jdk.internal.loader.ClassLoaders$AppClassLoader, com/company/project/common/servlet/PrintWriterResponseHandler, null, protectionDomain, 3215) This feature requires ASM7 java.lang.UnsupportedOperationException: This feature requires ASM7 at org.shaded.objectweb.asm.ClassVisitor.visitNestMember(ClassVisitor.java:249) at org.shaded.objectweb.asm.ClassReader.accept(ClassReader.java:670) at org.shaded.objectweb.asm.ClassReader.accept(ClassReader.java:401) at cn.myperf4j.asm.aop.ProfilingTransformer.getBytes(ProfilingTransformer.java:59) at cn.myperf4j.asm.aop.ProfilingTransformer.transform(ProfilingTransformer.java:38) at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:246) at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188) at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:563) at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at com.company.project.common.servlet.AbstractServlet$ResponseManager.getPrintWriterHandler(AbstractServlet.java:945) at com.company.project.common.servlet.AbstractServlet.sendOkResponse(AbstractServlet.java:759) at com.company.project.servlets.DaoSize.doGetBackgroundUnderLock(DaoSize.java:31) at com.company.project.servlets.DaoSize.doGetBackgroundUnderLock(DaoSize.java:18) at com.company.project.common.servlet.AbstractServlet.lambda$doGet$0(AbstractServlet.java:140) at com.company.project.common.servlet.AbstractServlet$1.run(AbstractServlet.java:340) at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1454) at org.eclipse.jetty.server.AsyncContextState$1.run(AsyncContextState.java:153) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806) at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938) at java.base/java.lang.Thread.run(Thread.java:834)

LinShunKang commented 3 years ago

Hello, I just updated the ASM api version number to ASM8. You can try this one.

gamefundas commented 3 years ago

Thanks for the quick response. This resolved the error but I am not seeing anything being written to metric.log

I am using the following properties file (/org/myperf4j/myperf4j.properties)

Configure Application name

app_name = my-service

###############################################################################

Metrics Configuration

###############################################################################

Configure MetricsExporter type

log.stdout: Output to stdout.log in a standard formatted structure

log.standard: Output to disk in standard formatted structure

log.influxdb: Output to disk in InfluxDB LineProtocol format

http.influxdb: Output to InfluxDB server in InfluxDB LineProtocol format; need configure influxdb configurations.

metrics.exporter = log.standard

Config metrics log file, option

metrics.log.method = /org/myperf4j/metrics.log metrics.log.class_loading = /org/myperf4j/metrics.log metrics.log.gc = /org/myperf4j/metrics.log metrics.log.memory = /org/myperf4j/metrics.log metrics.log.buff_pool = /org/myperf4j/metrics.log metrics.log.thread = /org/myperf4j/metrics.log metrics.log.file_desc = /org/myperf4j/metrics.log metrics.log.compilation = /org/myperf4j/metrics.log

###############################################################################

Filter Configuration

###############################################################################

Configure packages, separated with ';'

filter.packages.include = com.company.*;

The java process startup has the following -javaagent:/org/myperf4j/myperf4j-asm-3.2.0.jar -DMyPerf4JPropFile=/org/myperf4j/myperf4j.properties

The only thing thats printed in my application logs are sort of the following for my classes 2021-01-04 15:52:20.388 [MyPerf4J] INFO [main] ProfilingTransformer.transform(jdk.internal.loader.ClassLoaders$AppClassLoader, com/company/project/extracts/OutboundExtract, classBeingRedefined, protectionDomain, 8527)...

With the above is it fair to expect some output being printed to /org/myperf4j/metrics.log? Am I missing something besides this?

LinShunKang commented 3 years ago

MyPerf4J default time slice is 60s, you can add these properties to MyPerf4J.properties file:

metrics.time_slice.method = 1000
metrics.time_slice.jvm = 1000
gamefundas commented 3 years ago

Noticed that it works with log.stdout exporter but not with log.standard Need to check if this has something to do with directory permissions.

Also these properties, is there a list to refer to. The one on the wiki, the param names look different than the one you have mentioned here.

LinShunKang commented 3 years ago

Hi, here is the Congifure wiki: Configuration

LinShunKang commented 3 years ago

And, users of MyPerf4J need to ensure that MyPerf4J has read and write permissions to the configured directories and files.

gamefundas commented 3 years ago

Thanks for your help.

I just noticed the folder didnt have permission for the metrics.log. Fixing that resolved the issue. Looking at the configuration there is something for http server ports. Does this mean the library exposes the metrics on a HTTP endpoint?

LinShunKang commented 3 years ago

Not yet, this built-in HTTP Server is currently only used to modify the debug status. However, I will support this feature in the next few months.