Added basic support for com.sun.net.httpserver.HttpServer (#1853)#1854
Added basic support for com.sun.net.httpserver.HttpServer (#1853)#1854SylvainJuge merged 14 commits intoelastic:masterfrom
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
|
Can somebody please do a review? |
|
@SylvainJuge Maybe you could have a look please? |
...m-jdk-httpserver-plugin/src/main/java/co/elastic/apm/agent/httpserver/HttpHandlerAdvice.java
Outdated
Show resolved
Hide resolved
|
|
||
| public class HttpHandlerInstrumentation extends ElasticApmInstrumentation { | ||
|
|
||
| @Override |
There was a problem hiding this comment.
Here it's relevant to override getTypeMatcherPreFilter to ensure that it's only applied within package com.sun.net.httpserver, otherwise that makes hasSuperType matcher expensive. This will make it work only with the implementations that are part of the JDK.
Alternatively, if you aim to extend support to implementations that might be provided through com.sun.net.httpserver.spi.HttpServerProvider, this would require to apply instrumentation at runtime when instances are returned by HttpServerProvider. This could easily be done in a follow-up PR unless required for your use-case.
There was a problem hiding this comment.
Thank you for your review.
I am fine with only instrumenting com.sun.net.httpserver Handler. But then the HttpHandlerTest passes no longer because of java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory. The reason for the exception is that com.sun.net.httpserver.* is loaded by the platform classloader which cannot load org/slf4j/LoggerFactory and neither can the agent class loader, because org/slf4j is not listed in co.elastic.apm.agent.bci.classloading.IndyPluginClassLoaderParent#agentPackages. This is not an issue in the release build because org/slf4jis shaded.
How should I proceed? Remove the logger? Remove the test?
...pserver-plugin/src/main/java/co/elastic/apm/agent/httpserver/HttpHandlerInstrumentation.java
Outdated
Show resolved
Hide resolved
|
I've modified a bit the implementation to instrument the I also managed to reproduce the issue with |
|
Thank You for working on this. |
|
For the record, the |
|
Thank You! |
|
Thank for your contributions! if you haven't subscribed already you might be interesting by the Elastic Contributor program : https://www.elastic.co/community/contributor |
What does this PR do?
Fixes #1853
Checklist