signoz | It helps developers monitor | Monitoring library
kandi X-RAY | signoz Summary
kandi X-RAY | signoz Summary
Being developers, we found it annoying to rely on closed source SaaS vendors for every small feature we wanted. Closed source vendors often surprise you with huge month end bills without any transparency. We wanted to make a self-hosted & open source version of tools like DataDog, NewRelic for companies that have privacy and security concerns about having customer data going to third party services. Being open source also gives you complete control of your configuration, sampling, uptimes. You can also build modules over SigNoz to extend business specific capabilities.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of signoz
signoz Key Features
signoz Examples and Code Snippets
Community Discussions
Trending Discussions on signoz
QUESTION
I have a springboot application which I'm trying to instrument using bytebuddy. I'm running into classpath issues which I'm not able to understand.
Firstly, the following is other literature on this:
https://github.com/raphw/byte-buddy/issues/473
https://github.com/raphw/byte-buddy/issues/87
Unable to instrument apache httpclient using javaagent for spring boot uber jar application
https://github.com/raphw/byte-buddy/issues/109
https://github.com/raphw/byte-buddy/issues/473
https://github.com/raphw/byte-buddy/issues/489
https://github.com/spring-projects/spring-boot/issues/4868
https://github.com/alibaba/transmittable-thread-local/issues/161
Problem is that Spring-boot bundles the application into one uber-jar, which contains other jars inside it
A thing to note here is, that if I run the application using IntelliJ, it doesn't use the uber-jar and runs via main class with a bunch of jars as classpath arguments.
Due to this difference, When running via uber-jar(java -jar target/demo-0.0.1-SNAPSHOT.jar
), some classes are not available at the time the Agent runs. The classes are loadable at the time of application main, as spring-boot uses its own classloader, which is created at some time b/w agent and application main methods.
I'll describe the behaviour at various points of time below:
At time of PreMain of AgentThread.currentThread().getContextClassLoader() = Launcher$AppClassLoader
Agent.class.classLoader = Launcher$AppClassLoader
Class.forName("org.springframework.web.servlet.HandlerAdapter") => ClassNotFoundException
Class.forName("javax.servlet.http.HttpServletRequest") => ClassNotFoundException
Both spring and javax classes are not loaded as they are not directly in the classpath as per the App Classloader. It's part of an inner jar, something like app.jar!/BOOT-INF/lib/some.jar
App Classloader won't be able to load this.
Thread.currentThread().getContextClassLoader() =
org.springframework.boot.loader.LaunchedURLClassLoader
DemoApplication.class.classloader = same as above
Class.forName("org.springframework.web.servlet.HandlerAdapter") => loads successfully
- Same for javax class, loads successfully.
After loading, Class.forName("javax.servlet.http.HttpServletRequest").classLoader
is also the same LaunchedURLClassLoader
.
builder.visit
call (when bytebuddy is modifying the class definitions)
Code:
I have two classes, SpringBootInterceptor
(which contains the intercept method) and SpringBootInterceptorOne
(which contains the entry and exit method)
ANSWER
Answered 2020-Feb-17 at 21:43The problem is that the advice class will be loaded on the system class loader as a part of the agent whereas the actual application code is loaded on a sub-class loader that is not visible to the system class loader. This situation does not change if you load your agent on the boot loader either. Therefore, the agent cannot load the HttpServletRequest
class which is part of the uber-jar.
This is a typical problem with agents and Byte Buddy has a standard way to circumvent it by using a Transformer.ForAdvice
instance instead of using the Advice
class directly. Byte Buddy then creates a virtual class loader hierarchy that considers classes represented by both class loaders.
Update: The problem is that you are calling down to your interceptor that is defined in the system class loader where the class in question is not available. The annotated code will be inlined but the invoked method will not. If you copy-pasted the code into the annotated method, the behavior is as you'd expect it. Byte Buddy uses the annotated code as template and reuses a lot of information emitted by javac to guarantee a speedy conversion. Therefore, the library cannot simply copy the method and should rather feed the entire method body to javac.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install signoz
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page