javamelody / grails-melody-plugin

JavaMelody monitoring plugin for Grails, to monitor application performance
https://plugins.grails.org/plugin/grails-melody-plugin
Apache License 2.0
32 stars 31 forks source link

Showing SQL connections in "Statistics sql" #56

Closed MiguelAngel82 closed 6 years ago

MiguelAngel82 commented 6 years ago

Hi everyone.

I've been trying the plugin with a simple Grails 3 app but I cannot see SQL statistics by default when I access to "monitoring" page.

I've tried some suggested workarounds like this and that, but it doesn't work. For the last suggestiond I've tried this piece of code, in build.gradle:

bootRun {
    jvmArgs('-Djavamelody.datasources=java:comp/env/jdbc/dataSource')
    addResources = true
}

But it doesn't work. Maybe I've made some mistake, because showing JavaMelody log I can see this:

Sun Mar 11 20:03:37 CET 2018     DEBUG     JavaMelody listener init started
Sun Mar 11 20:03:37 CET 2018     DEBUG     rebinding datasources failed, skipping

Probably, all of this is related to the issue "JDBC DataSource is not wrapped, SQL requests are not monitored". If so, please, let me know what I'm doing wrong because, by default, it does not show SQL statistics.

Thank you very much.

Kind regards, Miguel.

MiguelAngel82 commented 6 years ago

This responds myself:

Looking on the JDBC JavaMelody documentation, I've seen that if you add the driver class to net.bull.javamelody.JdbcDriver it works. So this configuration, in application.yml works:

dataSource:
    [...]
    driverClassName: net.bull.javamelody.JdbcDriver
   [...]

environments:
    development:
        dataSource:
            dbCreate: create-drop
            url: jdbc:mysql://localhost:3306/test?driver=com.mysql.jdbc.Driver

But I'm not sure if this is the best approach or it could work with the javamelody.datasources property mentioned before.

sergiomichels commented 6 years ago

Configuring the Java Melody JdbcDriver is an workaround and shouldn't be needed. The aim of this plugin is to configure all DataSources automatically.

What happens is that sometimes Grails changes the way that this beans are declared and we need to adapt the plugin.

I opened issue #59, so we can improve the stability of the plugin by testing it on new versions of Grails.