Open WimLambrecht opened 5 years ago
This sounds like a bug. It does not seem related to missing settings. The only thing that starts a thread is the built-in server https://github.com/fstab/promagent/blob/master/promagent-framework/promagent-internal/src/main/java/io/promagent/internal/BuiltInServer.java. If you start promagent without the port
parameter this server will not be started. You could try that to check if this is the process preventing shutdown.
Indeed, after starting without the port, the process shuts down gracefully. As a solution: maybe you can register a VM-shutdownhook that provides a httpServer.stop(...) to gracefully shutdown the httpServer instance? P.S. not sure how this affects non-standalone-Tomcat usages of the promagent though (I did not look into it (yet) though).
It would be interesting to see if a shutdown hook works. If you try this and it works, please open a pull request.
Alternatively, there are other ways to expose the metrics (see https://github.com/fstab/promagent#exposing-metrics):
promagent.war
and it will expose the metrics.A yeah, ok, that's right. I blindly went with the javaagent approach some time ago and forgot all about those alternatives. Since i already use the JMX exporter for some other cases - on the same Tomcat app and thus already present - i'll first go with that one and try that path.
The promagent.war approach like promising also, it fits the Catalina approach, and i'll definitely try that one also.
About the shutdown hook; if i find the time i'll definitely try that one too. And if it's valuable, i'll open a pull request.
Thanks for the help (and i'll confirm if those alternatives work for me) !
Hi,
I've visited several forums and could not find a similar issue (with javaagent in general that is). I'm kinda stuck (in the last mile) for the moment ...
Some context and the issue:
I'm trying to use the 'promagent' instrumention in a standalone Tomcat context. I've made an agent implementation based on your promagent-example. It's actually very similar to your 'ServletHook' -example. So it's affecting the Servlet and ServletFilter implementation. I've provided this/my java agent on the Tomcat process (at startup) via the CATALINA_OPTS settings like this:
_export CATALINA_OPTS=" $CATALINAOPTS -javaagent:./promagent.jar=port=40111 "
Further:
The issue:
When execute a 'catalina.sh stop' to shutdown the app/service (again: with the CATALINA_OPS still in effect) ... :
So: the question is; how can a avoid this error and/or how to setup the promagent in a Tomcat standalone context.
P.S. & FYI:
Thank you for any pointers, help, ... !
Best regards, Wim.