Closed AlejandroRivera closed 8 years ago
Very interesting idea! I'll look this over.
Btw, i just ran into some issues because the JAR currently being generated is ab uber (shaded) jar. When the JAR is added as a maven/ivy/gradle/sbt dependency, this causes conflicts if the project is already relying on the same libraries (guava, jackson for example) but perhaps different versions.
I'm trying to think of a way that preserves backwards compatibility with your current design, but allows for a non-shaded JAR. I'm reading the maven-shade-plugin to see if it's possible to generate two artifacts (artifact.jar
and artifact-core.jar
), or maybe consider using separate maven profiles, but maybe you have a better idea.
That's a fair point, and an issue I hadn't run into because all the library versions match up with what we use internally :)
I've opened https://github.com/etsy/statsd-jvm-profiler/issues/33 to look into a solution; I think can use the maven-assembly-plugin to build both a standard and uberjar
Thanks again for this! I'll publish a release with this included once I work out the uberjar thing.
Sweet! good luck!
I've just published version 1.0.0 that contains this feature as well as fixes the issue with the uberjar. The Maven coordinates for the standard and uberjar are here: https://github.com/etsy/statsd-jvm-profiler#installation
Well that was quick!
You might want to update the usage section to reflect using the uber-jar for the -javaagent
command line approach.
Yeah, it turns out maven-shade-plugin already had that feature, it just had to be turned on!
Good call on updating the usage instructions.
Actually, I realized that the maven-shade-plugin approach isn't doing the right thing. The Premain-Class
and Agent-Class
settings are only applied to the uberjar. I'll have to look into it more.
Try with:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Agent-Class>com.etsy.statsd.profiler.Agent</Agent-Class>
<Premain-Class>com.etsy.statsd.profiler.Agent</Premain-Class>
</manifestEntries>
</archive>
</configuration>
</plugin>
(Updated comment to fix the Premain name)
Thanks, that did it. I've publish version 1.0.1 with the manifest entries set correctly.
This PR adds the ability for the JVM Profiler Agent to be loaded dynamically after the VM has already started.
The code was inspired from a blog post and from reading: Oracle's Starting Agents After VM Startup