-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Javamelody support #450
Javamelody support #450
Conversation
…used (e.g. using method shorthands)
You could turn the |
* register and unregister applications. Using the {@link EventListener annotations} we receive notifications from service discovery. | ||
*/ | ||
@Service | ||
public class JavaMelodyService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are missing for this class.
* Service class in the javamelody package, so we can access the javamelody Parameters class in which we can | ||
* register and unregister applications. Using the {@link EventListener annotations} we receive notifications from service discovery. | ||
*/ | ||
@Service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't rely on component scan - it might be disabled in the users' projects... since the service is in the config just remove the annotation
Sorry for coming back to this PR this late. Looking good so far. I left you some comments on minor issues. coul you also add a short chapter to the docs on how to use this module? |
Late reply from my side as well :) Here are the requested changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional to the blocker (see comment in net.bull.javamelody.JavaMelodyService) the JavaMelodyServiceTest fails.
@@ -0,0 +1,46 @@ | |||
package net.bull.javamelody; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that I spotted the foreign package declaration this late, but we can't include classes in foreign packages. It must be a de.codecentric
package.
The downside seems that you cannot access the net.bull.javamelody.Parameters
. So either you ask the javamelody guys to add a java-api to register applications in java melody or you need to make a post request to javameldoy's CollectorServlet
.
I created an issue with the Javamelody project javamelody/javamelody#661 |
javaMelody.addUrlPatterns("/*"); | ||
javaMelody.setFilter(filter); | ||
return javaMelody; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of javamelody-core dependency and of javaMelody FilterRegistrationBean (which is not enough anyway), I suggest to show an example to add javamelody-spring-boot-starter in pom.xml. For example:
<!-- https://github.com/javamelody/javamelody/wiki/SpringBootStarter -->
<dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-spring-boot-starter</artifactId>
<version>${javamelody.version}</version>
</dependency>
<groupId>net.sf.ehcache</groupId> | ||
<artifactId>ehcache-core</artifactId> | ||
<version>${ehcache.version}</version> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ehcache dependency is not needed here anymore: it can be removed.
And I suggest to add the iText 2.1.7 dependency (licence MPL or LGPL at your choice) and the Log4J dependency, in order to have PDF links in reports (I think PDF links are important in the reports) and to have some logs:
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
<exclusions>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bcmail-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bcprov-jdk14</artifactId>
</exclusion>
<exclusion>
<artifactId>bctsp-jdk14</artifactId>
<groupId>bouncycastle</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
You could also copy the collector server log4j.xml file in resources of this module.
And XStream 1.4.10 dependency and aws-java-sdk-cloudwatch dependency could possibly be added to be able to export data as JSON or XML and to export data to AWS CloudWatch, but they are less important and I suppose that they could be added by the "admin" user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we add this in the documentation instead of the pom.xml so users can choose for themselves if they want javamelody reporting to work. Personally I don't use it and rather don't have a transitive log4j/itext dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think that many users would be really happy to have the pdf reports. And, adding a iText dependency would be debatable in a monitored app but this dependency (with exclusions on transitive dependencies) is in my opinion not a problem in spring-boot-admin. So I think that we should really keep the iText dependency like it is now.
For Log4J, it is not included at the moment and finally it seems not needed since there is already a log4j-over-slf4j dependency in spring-boot-admin.
javaMelodyFilterBean.addServletNames("monitoring"); | ||
javaMelodyFilterBean.addUrlPatterns("/*"); | ||
return javaMelodyFilterBean; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This filterRegistrationBean() is not needed to make the collector server work and it should be removed I suppose. (There is a CollectorServlet below.)
Or if what you want is to monitor the spring-boot-admin server itself, then it is not enough (javamelody-spring-boot-starter may be better for this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to monitor spring boot admin itself. Why is this not enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FilterRegistrationBean is not enough because in general a SessionListener is also installed. See https://github.com/javamelody/javamelody/blob/master/javamelody-spring-boot-starter/src/main/java/net/bull/javamelody/JavaMelodyAutoConfiguration.java#L87
Then the spring-boot-starter also adds monitoring of RestControllers, RestTemplates, Services, spring context and more.
So adding the javamelody-spring-boot-starter to monitor the spring-boot-admin server should be much simpler than adding filter, sessionlistener, etc.
final String applicationName = application.getName() + "-" + application.getId(); | ||
|
||
try { | ||
Parameters.addCollectorApplication(applicationName, Parameters.parseUrl(application.getServiceUrl())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameters.addCollectorApplication(applicationName, Parameters.parseUrl(application.getServiceUrl()));
to be replaced by CollectorServlet.addCollectorApplication(applicationName, application.getServiceUrl())
(using the latest javamelody-core snapshot)
final String applicationName = application.getName() + "-" + application.getId(); | ||
|
||
try { | ||
Parameters.removeCollectorApplication(applicationName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be replaced by CollectorServlet.removeCollectorApplication(applicationName);
<artifactId>spring-boot-admin-server-ui-javamelody</artifactId> | ||
|
||
<properties> | ||
<javamelody.version>1.67.0</javamelody.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<javamelody.version>1.69.0</javamelody.version>
can now be used to use the new methods in CollectorServlet
What is currently preventing this pull request from being merged? |
Sorry I'm currently short on time. And currently want to invest the spare time into the adaption of spring boot 2.0. |
bdfc23b
to
1279ae8
Compare
So will you rework the code for 2.x? |
8ef0059
to
d7acee4
Compare
Do you mean rework the PR (as a new PR certainly) to work with spring-boot-admin 2.0.0-SNAPSHOT? |
@evernat I guess (mostly) all of it has to be reworked. The ui is now using Vue instead of Angular and also the backend has now a slightly different domain model. |
I agree. Will close this PR |
Very basic setup to add a tab for javamelody
In your SBA project add a depencendy for spring-boot-admin-server-ui-javamelody
Requires the following Configuration class in your SBA project